Lisp hatch nhanh theo layer
Bạn thử nhé :
- Tải lisp
- 193120_hlay.lsp
Cách dùng
- Tải tệp 193120_hlay.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 HLAY để chạy lisp.
Mã nguồn 193120_hlay.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/62595-y%C3%AAu-c%E1%BA%A7ulisp-hatch-nhanh-theo-layer/
(defun c:hlay(/ ss Tue-dxf Tue-ent-Lpoint ename ename2 ss2 lh)
(defun Tue-dxf (dxf ename)(cdr(assoc dxf (entget ename))))
(defun lh(dt name tle goc)
(setvar "hpgaptol" 50.0)
(vl-cmdf "bhatch" "P" name tle goc "S" dt "" "")
)
(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
)
(if (setq ss (ssget '((0 . "*POLYLINE") (8 . "NVSS"))))
(Progn
;(command "hatch" "P" "ANSI31" "1" "0" "")
(setq i -1)
(while (setq ename (ssname ss (setq i (1+ i))))
(setq ss2 (ssget "f" (Tue-ent-Lpoint ename) '((0 . "*POLYLINE") (8 . "NVSS,TUNHIEN"))))
(lh ss2 "ANSI31" "1" "0")
)
))
)
Thảo luận gốc
Lisp được chia sẻ trong chủ đề [Yêu cầu]Lisp hatch nhanh theo layer. Xem đúng bài viết #193120 để đọc hướng dẫn và trao đổi thêm.