Thứ Năm, 14 tháng 7, 2011

Lisp vẽ pline mũi tên 2 đầu

Nhân dịp có người nhờ chỉnh lisp của người khác nhưng đọc lisp lòi mắt mệt quá nên mình banh ra viết lại tuốt nên giới thiệu luôn đây.
-Tên lệnh: 2MT.
-Chọn điểm thứ nhất, chọn các điểm tiếp theo kết thúc thì enter.
-Điểm đầu và điểm cuối sẽ có dấu mũi tên hình tam giác (giá trị mặc định là 250, có thể nhập giá trị khác).
-Các điểm bên trong xét cặp 3 điểm liền kề nếu thẳng hàng thì vẽ hình tròn vào điểm thứ 3 và thứ 2 (bán kính mặc định 50, có thể nhập giá trị khác)
Bạn copy nội dung và tạo file lisp hay tải file về cũng được!


(defun c:2mt(/ tinhtrangtron)
(command "undo" "be")

(vl-load-com)

(if (null dlmt)(setq dlmt "250"))
(if (null dlvt)(setq dlvt "50"))
(Setq temp T)
(While temp
(setq po1 (strcat "\ndo lon Mui ten la(" dlmt ")/ Do lon Vong tron (" dlvt "): "))
(Initget "m M v V")
(setq str (getpoint po1))
(Cond
((= str "m") (setq dlmt (getstring (strcat"\nDo lon mui ten <" dlmt "> :"))))
((= str "M") (setq dlmt (getstring (strcat"\nDo lon mui ten <" dlmt "> :"))))
((= str "V") (setq dlvt (getstring (strcat"\nDo lon vong tron <" dlvt "> :"))))
((= str "v") (setq dlvt (getstring (strcat"\nDo lon vong tron <" dlvt "> :"))))
(Progn
(Setq po1 str)
(setq temp nil)
)
)
)

(setq dlmtt (atof dlmt))

(setq po2 (getpoint po1"\n Chon diem tiep theo :"))
(setq luubatdiem (getvar "osmode"))
(setvar "osmode" 0)
(command "pline" po1 "w" 0 (/ dlmtt 2) (polar po1 (angle po1 po2) dlmtt) "w" 0 0 po2 "")
(setvar "osmode" luubatdiem)
(setq La (entlast))
(setq sht 0)

(while (setq po3 (getpoint po2"\nChon diem tiep theo : "))
(setq luubatdiem (getvar "osmode"))
(setvar "osmode" 0)
(command "pline" po2 po3 "")
(setvar "osmode" luubatdiem)
(command "pedit" "m" "L" La "" "j" "0" "")
(setq La (entlast))
(cond
((/= (angle po1 po2) (angle po2 po3))
(setq tinhtrangtron "ko")
(if (/= sht 0)(command "erase" vtr ""))
(setq sht 0))
((= (angle po1 po2) (angle po2 po3))
(setq sht (+ 1 sht))
(setq luubatdiem (getvar "osmode"))
(setvar "osmode" 0)
(command ".circle" po3 dlvt)
(setq vtr (entlast))
(if (= sht 1)(command ".circle" po2 dlvt))
(setq tinhtrangtron "co")
(setvar "osmode" luubatdiem)
)
)
(setq po1 po2)
(setq po2 po3)
)

(if (= tinhtrangtron "co")(command "erase" vtr ""))
(setq luubatdiem (getvar "osmode"))
(setvar "osmode" 0)
(command "pline" po2 "w" 0 (/ dlmtt 2) (polar po2 (angle po2 po1) dlmtt) "")
(setvar "osmode" luubatdiem)
(command "pedit" "m" "L" La "" "j" "0" "")
(command "undo" "end")
(princ)
)




Không có nhận xét nào:

Đăng nhận xét