: Lisp ghi kích thước
Em có cái lisp ghi kích thước sưu tầm được của 1 bác trên diễn đàn. Xin các bác giúp em chỉnh sửa lisp này để có thể chọn đường thằng cần ghi kích thước theo một layer nào đó. Thanks!
;----kich thuoc duong thang --------
(defun c:kt2(/ vl ov ss d1 d2 d3 d4 d5 ent kc)
(vl-load-com)
(command "_.undo" "_begin")
(setq vl '("osmode" "orthomode" "cmdecho") ; Sys Var list
ov (mapcar 'getvar vl)) ; Get Old values
(mapcar 'setvar vl '(0 0 0))
(princ "\nChon duong thang can ghi kich thuoc : ")
(if (and
(setq ss (ssget (list (cons 0 "LINE")) ))
(setq kc (getdist "\nNhap khoang cach : "))
(setq d4 (getpoint "\nHuong dat kich thuoc ? ") ) )
(foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
(setq d1 (vlax-curve-getStartPoint ent)
d2 (vlax-curve-getEndPoint ent)
d5 (vlax-curve-getClosestPointTo ent d4 T)
d3 (polar d5 (angle d5 d4) kc))
(command "dimaligned" d1 d2 d3)
)
)
(mapcar 'setvar vl ov) ; reset Sys Vars
(command "_.undo" "_end")
(princ)
)
;----kich thuoc duong thang --------
(defun c:kt2(/ vl ov ss d1 d2 d3 d4 d5 ent kc)
(vl-load-com)
(command "_.undo" "_begin")
(setq vl '("osmode" "orthomode" "cmdecho") ; Sys Var list
ov (mapcar 'getvar vl)) ; Get Old values
(mapcar 'setvar vl '(0 0 0))
(princ "\nChon duong thang can ghi kich thuoc : ")
(if (and
(setq ss (ssget (list (cons 0 "LINE")) ))
(setq kc (getdist "\nNhap khoang cach : "))
(setq d4 (getpoint "\nHuong dat kich thuoc ? ") ) )
(foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
(setq d1 (vlax-curve-getStartPoint ent)
d2 (vlax-curve-getEndPoint ent)
d5 (vlax-curve-getClosestPointTo ent d4 T)
d3 (polar d5 (angle d5 d4) kc))
(command "dimaligned" d1 d2 d3)
)
)
(mapcar 'setvar vl ov) ; reset Sys Vars
(command "_.undo" "_end")
(princ)
)
- Tải lisp
- 207188_kt2.lsp
Cách dùng
- Tải tệp 207188_kt2.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 KT2 để chạy lisp.
Mã nguồn 207188_kt2.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/65459-nh%E1%BB%9D-ch%E1%BB%89nh-s%E1%BB%ADa-lisp-ghi-k%C3%ADch-th%C6%B0%E1%BB%9Bc/
;----kich thuoc duong thang --------
(defun c:kt2(/ vl ov ss d1 d2 d3 d4 d5 ent kc)
(vl-load-com)
(command "_.undo" "_begin")
(setq vl '("osmode" "orthomode" "cmdecho") ; Sys Var list
ov (mapcar 'getvar vl)) ; Get Old values
(mapcar 'setvar vl '(0 0 0))
(princ "\nChon duong thang can ghi kich thuoc : ")
(if (and
(setq ss (ssget (list (cons 0 "LINE")) ))
(setq kc (getdist "\nNhap khoang cach : "))
(setq d4 (getpoint "\nHuong dat kich thuoc ? ") ) )
(foreach ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
(setq d1 (vlax-curve-getStartPoint ent)
d2 (vlax-curve-getEndPoint ent)
d5 (vlax-curve-getClosestPointTo ent d4 T)
d3 (polar d5 (angle d5 d4) kc))
(command "dimaligned" d1 d2 d3)
)
)
(mapcar 'setvar vl ov) ; reset Sys Vars
(command "_.undo" "_end")
(princ)
)
Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Nhờ chỉnh sửa]: Lisp ghi kích thước. Xem đúng bài viết #207188 để đọc hướng dẫn và trao đổi thêm.