仅分解嵌套块
你好试图寻找类似主题所说的内容,但只找到了能爆炸一切的主题。我只想分解块内的块,然后保留放置的主块。
我有数百个街区,其中一些在一个街区内,所以自动的东西会很好
谢谢你的帮助
厘米 我已经将您的帖子转移到AutoLISP、Visual LISP和DCL论坛。 请参见此处:
http://www.cadtutor.net/forum/showthread.php?72399-仅分解嵌套块&p=636640&viewfull=1#post636640
不错,需要递归
我在尝试迭代方法时很开心:
(defun C:test ( / o n L b)
(defun Bdef->SubentsL ( nm / e L )
(setq e (cdr (assoc -2 (entget (tblobjname "BLOCK" nm)))))
(while e (setq L (cons e L)) (setq e (entnext e))) L
)
(and
(setq n (car (entsel "\nSelect block to \"flatten\": ")))
(setq n (vlax-ename->vla-object n))
(setq n (vla-get-EffectiveName n))
(progn
(while
(vl-some
(function
(lambda (x / o)
(and
(= "INSERT" (cdr (assoc 0 x)))
(setq L (cons (cdr (assoc 2 x)) L))
(setq o (vlax-ename->vla-object (cdr (assoc -1 x))))
(vlax-write-enabled-p o)
(not (vl-catch-all-error-p (vl-catch-all-apply 'vla-Explode (list o))))
(not (vla-Delete o))
)
)
)
(mapcar 'entget (Bdef->SubentsL n))
)
); while
(and (= "Yes" (progn (initget "Yes No") (cond ((getkword "\nAttempt to purge the SubBlocks? <Yes>: ")) ("Yes"))))
(setq b (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))))
(foreach x L (vl-catch-all-apply 'vla-Delete (list (vla-item b x))) )
); and
); progn
); and
(princ)
); defun
页:
[1]