@koolestani wrote:
... the former is what needs to happen. Yes, the groups can be unnamed, with no attributes involved.
This seems to do that, in limited testing:
(defun C:B2G ; = Blocks {to} Groups
(/ bsel bdata bname ct bss n blk)
(if
(and
(setq bsel (entsel "\nSelect Block to have all instances turned into Groups: "))
(= (cdr (assoc 0 (setq bdata (entget (car bsel))))) "INSERT")
(not (assoc 1 (tblsearch "block" (setq bname (cdr (assoc 2 bdata)))))); not Xref
); and
(progn ; then
(setq ct (getvar 'ctab))
(setq bss (ssget "_X" (list '(0 . "INSERT") (cons 2 bname))))
(repeat (setq n (sslength bss))
(setq blk (ssname bss (setq n (1- n))))
(setvar 'ctab (cdr (assoc 410 (entget blk))))
(command "_.explode" blk)
(initcommandversion)
(command "_.group" (ssget "_P") "")
); repeat
(setvar 'ctab ct)
); progn
); if
(princ)
); defun
It gets them in all Model/Layout spaces. It relies on the Block in question being defined to allow Exploding, but if that can't be relied on, it could be made to check for that, and if it's not, either change that or ask the User whether to change that. It also expects that all insertions will be on unlocked and thawed/on Layers, but those possibilities could be accounted for.
It could be made to suppress command echoing, have *error* handling to ensure resetting stuff, put an Undo begin/end wrapping around it all, etc., but first see whether it does what you're after.
Kent Cooper, AIA