Lệnh CA2P
Chuyển đổi Circle thành Point trong bản vẽ AutoCAD
1 Thêm class CA2P.lsp
Lưu mã sau dưới dạng tệp tin CA2P.lsp
Code:
(defun C:ca2p ( / A A1 B C D n del) (if ;Check for selection. If nothing is selected, the lisp exit quietly. ;Without this check, (sslength A) result is an error (and ;filter selection set to circles and arcs only (setq A (ssget "_:L" '((0 . "CIRCLE,ARC")))) (progn ;option to delete the circles or not (initget "Yes No") (setq del (getkword "\nDelete the circles [Yes/No] <No>: ")) T ) ) (progn ;inititalize loop (setq n 0) (setq B (sslength A)) ;start loop (while (< n B) ; "n < B" doesn't work, everything in lisp should be a list (setq C (ssname A n) ; get entity from selection set D (entget C) ; get entity definition A1 (cdr (assoc 0 D)) ; get entity type ) (cond ;(cond (<test1> <result1>) (<test2> <result2>) ...) ;<test> is the first element to be evaluated. ;in ( = "CIRCLE" A1 ...) the first element is "=", which is always not nil, so it's True ;in ((= "CIRCLE" A1) ...) the first element is "(= "CIRCLE" A1)" ((= "CIRCLE" A1) (entmakex (list (cons 0 "point") (assoc 10 D))) (if (eq del "Yes") (entdel C)) ) ((= "ARC" A1) (entdel C)) ) (setq n (+ n 1)) ) ) ) (princ "https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/circle-amp-arc-to-point-autolisp/td-p/9890685") (princ "Share on lisp.vn") )
Nguồn
Link tải (MediaFire)
---------------------------------------------------------------------------------------------
Mọi thông tin xin liên hệ Fanpage AutoLISP Thật là đơn giản!
Cảm ơn bạn đã theo dõi!
Không có nhận xét nào:
Đăng nhận xét