Viết lisp vẽ 1 đường Line có ghi luôn kích thước của Line đó
Xem cái này thế nào: Lệnh là LKT
(defun c:lkt ( )
(command "undo" "be")
(command "-style" "ktdt" "VNI-HELVE" "0" "1" "0" "n" "n")
(if (null dolora)(setq dolora "400"))
(Setq temp T)
(While temp
(setq a (strcat "\nD lon text hien hanh la (" dolora ") /<Diem dau tien>: "))
(Initget "d D")
(setq str (getpoint a))
(Cond
((= str "d") (setq dolora (getstring (strcat"\nDo lon text <" dolora "> :"))))
((= str "D") (setq dolora (getstring (strcat"\nDo lon text <" dolora "> :"))))
(Progn
(Setq a str)
(setq temp nil)
)
)
)
(setq b (getpoint a"\nChon diem tiep theo: "))
(setq luubatdiem (getvar "osmode"))
(setvar "osmode" 0)
(setq doclora (atof dolora))
(setq gocxeo(angle a
(setq daiab (distance a
(setq c (polar a gocxeo (/ daiab 2)))
(setq d (polar c (+ gocxeo (/ pi 2)) (/ doclora 4)))
(command ".line" a b "")
(command "text" "j" "c" c doclora b (rtos daiab 2 2) "")
(command ".move" "last" "" c d)
(cond
((> gocxeo (/ pi 2)) (command ".rotate" "last" "" c 180))
)
(setvar "osmode" luubatdiem)
(command "undo" "end")
(Princ)
)
- Tải lisp
- 176602_lkt.lsp
Cách dùng
- Tải tệp 176602_lkt.lsp về máy.
- Trong AutoCAD gõ lệnh APPLOAD, chọn tệp vừa tải rồi bấm Load. Cũng có thể kéo thả tệp .lsp vào cửa sổ bản vẽ.
- Gõ lệnh LKT để chạy lisp.
Mã nguồn 176602_lkt.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/57439-y%C3%AAu-c%E1%BA%A7u-vi%E1%BA%BFt-lisp-v%E1%BA%BD-1-%C4%91%C6%B0%E1%BB%9Dng-line-c%C3%B3-ghi-lu%C3%B4n-k%C3%ADch-th%C6%B0%E1%BB%9Bc-c%E1%BB%A7a-line-%C4%91%C3%B3/
(defun c:lkt ( )
(command "undo" "be")
(command "-style" "ktdt" "VNI-HELVE" "0" "1" "0" "n" "n")
(if (null dolora)(setq dolora "4"))
(Setq temp T)
(While temp
(setq a (strcat "\nD lon text hien hanh la (" dolora ") /<Diem dau tien>: "))
(Initget "d D")
(setq str (getpoint a))
(Cond
((= str "d") (setq dolora (getstring (strcat"\nDo lon text <" dolora "> :"))))
((= str "D") (setq dolora (getstring (strcat"\nDo lon text <" dolora "> :"))))
(Progn
(Setq a str)
(setq temp nil)
)
)
)
(setq b (getpoint a"\nChon diem tiep theo: "))
(setq luubatdiem (getvar "osmode"))
(setvar "osmode" 0)
(setq doclora (atof dolora))
(setq gocxeo(angle a B))
(setq daiab (distance a B))
(setq c (polar a gocxeo (/ daiab 2)))
(setq d (polar c (+ gocxeo (/ pi 2)) (/ doclora 4)))
(command ".line" a b "")
(command "text" "j" "c" c doclora b (rtos daiab 2 2) "")
(command ".move" "last" "" c d)
(cond
((> gocxeo (/ pi 2)) (command ".rotate" "last" "" c 180))
)
(setvar "osmode" luubatdiem)
(command "undo" "end")
(Princ)
)
Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Yêu cầu] Viết lisp vẽ 1 đường Line có ghi luôn kích thước của Line đó. Xem đúng bài viết #176602 để đọc hướng dẫn và trao đổi thêm.