Lisp lệnh DOP trong chủ đề “Nhờ Viết Lisp Dim hàng loạt theo phương đứng”
Cái UCS đó dùng như thế nào vậy bác Tue? Em chưa biết cách.
Còn sau đây e gửi bác cách em thường đo Dim với cái file cad của em. Bác xem và giúp em với nhé
Do chưa hiểu file của bạn....
Code Lisp của bạn đây:
(defun c:dop(/ Tue-dxf Tue-ent-Lpoint cur line dd) (vl-load-com) (defun Tue-dxf (dxf ename)(cdr(assoc dxf (entget ename)))) (defun Tue-ent-Lpoint(e / i Lpoint);Tue-dxf (if (wcmatch (Tue-dxf 0 e) "*POLYLINE") (progn (if (= (type e) 'VLA-OBJECT) (setq e (vlax-vla-object->ename e))) (setq i -1) (Repeat (if (wcmatch (Tue-dxf 0 e) "*POLYLINE") (fix (1+ (vlax-curve-getEndParam e))) 2) (setq Lpoint (append Lpoint (list (vlax-curve-getPointatParam e (setq i (1+ i)))))) ) ) ) (if (wcmatch (Tue-dxf 0 e) "LINE") (setq Lpoint (append Lpoint (list (Tue-dxf 10 e) (Tue-dxf 11 e)))) ) Lpoint ) (command "ucs" "W") (while (and (setq cur (car (entsel "\nChon Pline :"))) (setq line (car (entsel "\nChon line1 :"))) (setq dd (getpoint "\nChon diem dat :")) ) (foreach x (Tue-ent-Lpoint cur) (command "._dimlinear" x (vlax-curve-getClosestPointTo line x) x "._dimtedit" (entlast) (list (car x) (cadr dd) 0.0)) ) ) )
(defun c:dop(/ Tue-dxf Tue-ent-Lpoint cur line dd)
(defun Tue-dxf (dxf ename)(cdr(assoc dxf (entget ename))))
(defun Tue-ent-Lpoint(e / i Lpoint);Tue-dxf
(if (wcmatch (Tue-dxf 0 e) "*POLYLINE")
(progn
(if (= (type e) 'VLA-OBJECT) (setq e (vlax-vla-object->ename e)))
(setq i -1)
(Repeat (if (wcmatch (Tue-dxf 0 e) "*POLYLINE") (fix (1+ (vlax-curve-getEndParam e))) 2)
(setq Lpoint (append Lpoint (list (vlax-curve-getPointatParam e (setq i (1+ i))))))
)
)
)
(if (wcmatch (Tue-dxf 0 e) "LINE")
(setq Lpoint (append Lpoint (list (Tue-dxf 10 e) (Tue-dxf 11 e))))
)
Lpoint
)
(command "ucs" "W")
(while (and
(setq cur (car (entsel "\nChon Pline :")))
(setq line (car (entsel "\nChon line1 :")))
(setq dd (getpoint "\nChon diem dat :"))
)
(foreach x (Tue-ent-Lpoint cur)
(command "._dimlinear" x (vlax-curve-getClosestPointTo line x) x
"._dimtedit" (entlast) (list (car x) (cadr dd) 0.0))
)
)
)
- Tải lisp
- 276062_dop.lsp
Cách dùng
- Tải tệp 276062_dop.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 DOP để chạy lisp.
Mã nguồn 276062_dop.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/93263-nh%E1%BB%9D-vi%E1%BA%BFt-lisp-dim-h%C3%A0ng-lo%E1%BA%A1t-theo-ph%C6%B0%C6%A1ng-%C4%91%E1%BB%A9ng/
(defun c:dop(/ Tue-dxf Tue-ent-Lpoint cur line dd)
(vl-load-com)
(defun Tue-dxf (dxf ename)(cdr(assoc dxf (entget ename))))
(defun Tue-ent-Lpoint(e / i Lpoint);Tue-dxf
(if (wcmatch (Tue-dxf 0 e) "*POLYLINE")
(progn
(if (= (type e) 'VLA-OBJECT) (setq e (vlax-vla-object->ename e)))
(setq i -1)
(Repeat (if (wcmatch (Tue-dxf 0 e) "*POLYLINE") (fix (1+ (vlax-curve-getEndParam e))) 2)
(setq Lpoint (append Lpoint (list (vlax-curve-getPointatParam e (setq i (1+ i))))))
)
)
)
(if (wcmatch (Tue-dxf 0 e) "LINE")
(setq Lpoint (append Lpoint (list (Tue-dxf 10 e) (Tue-dxf 11 e))))
)
Lpoint
)
(command "ucs" "W")
(while (and
(setq cur (car (entsel "\nChon Pline :")))
(setq line (car (entsel "\nChon line1 :")))
(setq dd (getpoint "\nChon diem dat :"))
)
(foreach x (Tue-ent-Lpoint cur)
(command "._dimlinear" x (vlax-curve-getClosestPointTo line x) x
"._dimtedit" (entlast) (list (car x) (cadr dd) 0.0))
)
)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề Nhờ Viết Lisp Dim hàng loạt theo phương đứng. Xem đúng bài viết #276062 để đọc hướng dẫn và trao đổi thêm.