Lisp lệnh IBI trong chủ đề “Cần tìm Lisp chèn block tại các điểm giao nhau(intersection)”
Bạn thử cái này có đúng ý bạn không
(defun LM:IntersectionsinSet ( ss / a b i j l ) (setq i (sslength ss)) (while (not (minusp (setq j (1- i) i (1- i)))) (setq a (vlax-ename->vla-object (ssname ss i))) (while (not (minusp (setq j (1- j)))) (setq b (vlax-ename->vla-object (ssname ss j)) l (cons (LM:GroupByNum (vlax-invoke a 'IntersectWith b acExtendNone) 3) l) ) ) ) (apply 'append l) ) (defun LM:GroupByNum ( l n / r) (if l (cons (reverse (repeat n (setq r (cons (car l) r) l (cdr l)) r)) (LM:GroupByNum l n) ) ) ) (defun dxf (code e) (cdr (assoc code (entget e)))) (defun C:ibi(/ os ss lst en pt item) (setq os (getvar "osmode")) (setvar "osmode" 0) (princ "\n Chon cac doi tuong giao nhau") (setq ss (ssget) lst (LM:IntersectionsinSet ss) en (car (entsel "\nChon Block")) pt (dxf 10 en) ) (foreach item lst (command "copy" en "" pt item) ) (setvar "osmode" os) )
Cái này hay quá bác ah, tks bác :D
- Tải lisp
- 245155_ibi.lsp
Cách dùng
- Tải tệp 245155_ibi.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 IBI để chạy lisp.
Mã nguồn 245155_ibi.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from https://www.cadviet.com/forum/topic/3548-c%C3%A2%CC%80n-ti%CC%80m-lisp-che%CC%80n-block-ta%CC%A3i-ca%CC%81c-%C4%91i%C3%AA%CC%89m-giao-nhauintersection/
(defun LM:IntersectionsinSet ( ss / a b i j l )
(setq i (sslength ss))
(while (not (minusp (setq j (1- i) i (1- i))))
(setq a (vlax-ename->vla-object (ssname ss i)))
(while (not (minusp (setq j (1- j))))
(setq b (vlax-ename->vla-object (ssname ss j))
l (cons (LM:GroupByNum (vlax-invoke a 'IntersectWith b acExtendNone) 3) l)
)
)
)
(apply 'append l)
)
(defun LM:GroupByNum ( l n / r)
(if l
(cons
(reverse (repeat n (setq r (cons (car l) r) l (cdr l)) r))
(LM:GroupByNum l n)
)
)
)
(defun dxf (code e) (cdr (assoc code (entget e))))
(defun C:ibi(/ os ss lst en pt item)
(setq os (getvar "osmode"))
(setvar "osmode" 0)
(princ "\n Chon cac doi tuong giao nhau")
(setq
ss (ssget)
lst (LM:IntersectionsinSet ss)
en (car (entsel "\nChon Block"))
pt (dxf 10 en)
)
(foreach item lst
(command "copy" en "" pt item)
)
(setvar "osmode" os)
)Thảo luận gốc
Lisp được chia sẻ trong chủ đề Cần tìm Lisp chèn block tại các điểm giao nhau(intersection). Xem đúng bài viết #245155 để đọc hướng dẫn và trao đổi thêm.