Lisp lệnh CLEAR1 trong chủ đề “Nhờ viết lisp dọn mặt bằng siêu tốc”
Bạn thêm 1 dòng thôi là được. Tối r mình ngại upload quá, bạn chịu khó chép code nhé
(defun c:clear1() ;free lisp from CADviet.com @ketxu (vl-load-com) (command "undo" "be") (command "change" (ssget "X") "" "p" "c" "8" "") (if (ssget "x" '((0 . "INSERT")(66 . 1))) (progn (setq adoc (vla-get-activedocument (vlax-get-acad-object)) ss (vla-get-activeselectionset adoc) ) (vlax-for block (vla-get-blocks adoc) (if (not (wcmatch (strcase (vla-get-name block) t) "*_space*")) (vlax-for ent block (progn (vla-put-color ent "8") ) ) ) ) (vlax-for attblock ss (setq atts (vlax-invoke attblock 'getattributes)) (foreach att atts (vla-put-color att 8) ) ) );end progn );end if (acet-sysvar-set (list "dimclrt" 8 "dimclre" 8 "dimclrd" 8 "cmdecho" 0 "INSUNITS" 4 "INSUNITSDEFSOURCE" 4 "INSUNITSDEFTARGET" 4)) (command "dim1" "update" (ssget "X" '((0 . "Leader"))) "") (command "-layer" "c" "8" "*" "") (vla-regen adoc acactiveviewport) (command "-purge" "a" "" "N") (command "undo" "e") (princ))
chuẩn không cần chỉnh.
thank bác nhiều.
Tệp .lsp gốc không còn trên máy chủ. Hãy chép mã nguồn bên dưới (lấy từ bài viết gốc) vào một tệp văn bản, lưu với đuôi .lsp.
Cách dùng
- Chép mã nguồn, lưu thành tệp 136116_clear1.lsp.
- 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 CLEAR1 để chạy lisp.
Mã nguồn 136116_clear1.lsp (trích từ bài viết gốc)
(defun c:clear1()
;free lisp from CADviet.com @ketxu
(vl-load-com)
(command "undo" "be")
(command "change" (ssget "X") "" "p" "c" "8" "")
(if (ssget "x" '((0 . "INSERT")(66 . 1)))
(progn
(setq adoc (vla-get-activedocument (vlax-get-acad-object))
ss (vla-get-activeselectionset adoc)
)
(vlax-for block (vla-get-blocks adoc)
(if (not (wcmatch (strcase (vla-get-name block) t) "*_space*"))
(vlax-for ent block
(progn
(vla-put-color ent "8")
)
)
)
)
(vlax-for attblock ss
(setq atts (vlax-invoke attblock 'getattributes))
(foreach att atts
(vla-put-color att 8)
)
)
);end progn
);end if
(acet-sysvar-set (list "dimclrt" 8 "dimclre" 8 "dimclrd" 8 "cmdecho" 0 "INSUNITS" 4 "INSUNITSDEFSOURCE" 4 "INSUNITSDEFTARGET" 4))
(command "dim1" "update" (ssget "X" '((0 . "Leader"))) "")
(command "-layer" "c" "8" "*" "")
(vla-regen adoc acactiveviewport)
(command "-purge" "a" "" "N")
(command "undo" "e")
(princ))Thảo luận gốc
Lisp được chia sẻ trong chủ đề Nhờ viết lisp dọn mặt bằng siêu tốc. Xem đúng bài viết #136116 để đọc hướng dẫn và trao đổi thêm.