Lisp lệnh TEST trong chủ đề “làm thế nào để nối hatch???”
Bác Hoành có thể sửa được lỗi này không: khi các hatch giao nhau, ta dùng lệnh merge hatch thì tại các khoảng giao nhau đó sẽ thành khoảng trắng. (ý em là phải union hach kia chứ không phải merge hatch
)
Bạn dùng thử MergeHatch sau của hmsilva
http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Hatch-merge-split/td-p/3823971
(defun c:test (/ ss zer ss1 hpb olde itm ent bou ss2)
(alert
"\n Select hatch to Merge.\n\nFirst one will be the Properties Source."
)
(if (setq ss (ssget ":L" '((0 . "HATCH"))))
(progn
(command "_.undo" "_BE")
(setq olde (getvar 'cmdecho)
hpb (getvar 'hpbound)
itm -1
ss1 (ssadd)
zer (entlast)
)
(ssadd zer ss1)
(setvar 'hpbound 0)
(setvar 'cmdecho 0)
(while
(setq ent (ssname ss (setq itm (1+ itm))))
(command ".-hatchedit" ent "b" "r" "y")
);; while
(while
(setq zer (entnext zer))
(ssadd zer ss1)
);; while
(ssdel (ssname ss1 0) ss1)
(command "_.union" ss1 "")
(setq bou (entlast))
(command "_.hatch" "solid" "l" "")
(setq ss2 (ssget "_L"))
(command "_.copy"
(ssname ss 0)
""
"0,0,0"
"0,0,0"
"_.erase"
"p"
""
"_.matchprop"
"L"
ss2
""
"_.draworder"
ss2
""
"b"
"_.erase"
"L"
bou
ss
""
)
);; progn
);; if
(command "_.undo" "_E")
(setvar 'hpbound hpb)
(setvar 'cmdecho olde)
(princ)
);; test- Tải lisp
- 240539_test.lsp
Cách dùng
- Tải tệp 240539_test.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 TEST để chạy lisp.
Mã nguồn 240539_test.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/2375-l%C3%A0m-th%E1%BA%BF-n%C3%A0o-%C4%91%E1%BB%83-n%E1%BB%91i-hatch/
(defun c:test (/ ss zer ss1 hpb olde itm ent bou ss2)
(alert
"\n Select hatch to Merge.\n\nFirst one will be the Properties Source."
)
(if (setq ss (ssget ":L" '((0 . "HATCH"))))
(progn
(command "_.undo" "_BE")
(setq olde (getvar 'cmdecho)
hpb (getvar 'hpbound)
itm -1
ss1 (ssadd)
zer (entlast)
)
(ssadd zer ss1)
(setvar 'hpbound 0)
(setvar 'cmdecho 0)
(while
(setq ent (ssname ss (setq itm (1+ itm))))
(command ".-hatchedit" ent "b" "r" "y")
);; while
(while
(setq zer (entnext zer))
(ssadd zer ss1)
);; while
(ssdel (ssname ss1 0) ss1)
(command "_.union" ss1 "")
(setq bou (entlast))
(command "_.hatch" "solid" "l" "")
(setq ss2 (ssget "_L"))
(command "_.copy"
(ssname ss 0)
""
"0,0,0"
"0,0,0"
"_.erase"
"p"
""
"_.matchprop"
"L"
ss2
""
"_.draworder"
ss2
""
"b"
"_.erase"
"L"
bou
ss
""
)
);; progn
);; if
(command "_.undo" "_E")
(setvar 'hpbound hpb)
(setvar 'cmdecho olde)
(princ)
);; testThảo luận gốc
Lisp được chia sẻ trong chủ đề làm thế nào để nối hatch???. Xem đúng bài viết #240539 để đọc hướng dẫn và trao đổi thêm.