Lisp lệnh FOO trong chủ đề “Xin Lisp đo kích thước từ các điểm đỉnh polyline vuông góc với 1 đối tượng cho trước”
Quick code cho bạn, từ cái này bạn phát triển hay sửa lỗi j thì mần :)
(defun c:foo(/ _massoc e1 e2 p)
;Free from CADViet @ketxu
(command "undo" "be")
(defun _massoc (id eData / x l)
(foreach x eData
(if (eq id (car x))
(setq l (cons (cdr x) l))
)
)
(reverse l)
)
(if
(and
(setq e1 (entsel "\nObject 1:"))
(wcmatch (cdr (assoc 0 (entget (setq e1 (car e1))))) "LINE,LWPOLYLINE")
(setq e2 (entsel "\nObject 2:"))
(wcmatch (cdr (assoc 0 (entget (setq e2 (car e2))))) "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,SPLINE")
)
(progn
(setq l (_massoc 10 (entget e1)))
(mapcar
'(lambda(x)
(if (setq p (vlax-curve-getclosestpointto e2 x))
(command "dimaligned" "non" p "non" x (polar p (- (angle p x) (* pi 0.5)) 1))
)
)
l
)
)
)
(command "undo" "end")
(princ)
)
- Tải lisp
- 454669_foo.lsp
Cách dùng
- Tải tệp 454669_foo.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 FOO để chạy lisp.
Mã nguồn 454669_foo.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/185677-xin-lisp-%C4%91o-k%C3%ADch-th%C6%B0%E1%BB%9Bc-t%E1%BB%AB-c%C3%A1c-%C4%91i%E1%BB%83m-%C4%91%E1%BB%89nh-polyline-vu%C3%B4ng-g%C3%B3c-v%E1%BB%9Bi-1-%C4%91%E1%BB%91i-t%C6%B0%E1%BB%A3ng-cho-tr%C6%B0%E1%BB%9Bc/
(defun c:foo(/ _massoc e1 e2 p)
;Free from CADViet @ketxu
(command "undo" "be")
(defun _massoc (id eData / x l)
(foreach x eData
(if (eq id (car x))
(setq l (cons (cdr x) l))
)
)
(reverse l)
)
(if
(and
(setq e1 (entsel "\nObject 1:"))
(wcmatch (cdr (assoc 0 (entget (setq e1 (car e1))))) "LINE,LWPOLYLINE")
(setq e2 (entsel "\nObject 2:"))
(wcmatch (cdr (assoc 0 (entget (setq e2 (car e2))))) "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,SPLINE")
)
(progn
(setq l (_massoc 10 (entget e1)))
(mapcar
'(lambda(x)
(if (setq p (vlax-curve-getclosestpointto e2 x))
(command "dimaligned" "non" p "non" x (polar p (- (angle p x) (* pi 0.5)) 1))
)
)
l
)
)
)
(command "undo" "end")
(princ)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề Xin Lisp đo kích thước từ các điểm đỉnh polyline vuông góc với 1 đối tượng cho trước. Xem đúng bài viết #454669 để đọc hướng dẫn và trao đổi thêm.