@Migumby wrote:
I’m looking for a lsp that will explode all selected blocks that contain a layer named “text tags”.
Is such a thing even possible?
Hi Migumby,
if I have understood your goal, perhaps something like this...
(vl-load-com)
(defun c:demo (/ i lst lst1 name obj ss)
(or acdoc (setq acdoc (vla-get-activedocument (vlax-get-acad-object))))
(if (setq ss (ssget "_:L" '((0 . "INSERT"))))
(progn
(repeat (setq i (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))
name (vla-get-effectivename obj)
)
(if (not (vl-position name lst))
(setq lst (cons name lst))
)
)
(vlax-for blk (vla-get-blocks acdoc)
(if (and (= (vla-get-islayout blk) :vlax-false)
(= (vla-get-isxref blk) :vlax-false)
(vl-position (setq name (vla-get-name blk)) lst)
)
(vlax-for obj blk
(if (and (= (vla-get-layer obj) "text tags")
(not (vl-position name lst1))
)
(setq lst1 (cons name lst1))
)
)
)
)
(if lst1
(repeat (setq i (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i))))
name (vla-get-effectivename obj)
)
(if (and (vl-position name lst1)
(not (vl-catch-all-error-p (vl-catch-all-apply 'vlax-invoke (list obj 'explode))))
)
(vla-delete obj)
)
)
)
)
)
(princ)
)
Hope this helps,
Henrique