Hi,
I want to explode all objects inside a block (not the block itself). I created following program :-
(defun c:ExplodeInsideBlocks ()
(defun get-block-entities (blk / ent lst)
(if (and (setq blk (vla-get-effectivename (vlax-ename->vla-object blk)))
(setq ent (tblobjname "block" blk))
)
(while (setq ent (entnext ent)) (setq lst (cons ent lst)))
)
(reverse lst)
)
;;
(defun explodefunction (entnm / obj xx blkentlst)
(if (setq enx (entget entnm))
(progn (setq typ (strcase (cdr (assoc 0 enx))))
(if (and (eq typ "INSERT") (setq blkentlst (get-block-entities entnm)))
(progn ;;
(mapcar (function (lambda (xx)
(if (not (eq entnm xx))
(explodefunction xx)
)
)
)
blkentlst
)
)
(progn ;;
(command "_.explode" entnm)
)
)
)
)
)
(if (setq sset (ssget "_:L" (list (cons 0 "INSERT"))))
(repeat (setq n (sslength sset)) (setq ent (ssname sset (setq n (1- n)))) (explodefunction ent))
)
(princ)
)
When I use this function, I get following error :-
_.explode <Bad Entity name: DA71E400>
_.explode <Bad Entity name: DA71E410>
_.explode <Bad Entity name: DA71E420>
_.explode <Bad Entity name: DA71E430>
_.explode <Bad Entity name: DA71E440>
_.explode <Bad Entity name: DA71E450>
The reason I can think of is that the entity is inside block, hence could not be exploded.
But instead of "(command "_.explode" entnm)"
when I use "(vla-put-color (vlax-ename->vla-object entnm) 3)"
it works. I also tried "(vla-explode (vlax-ename->vla-object entnm))"
but it also does not work. When I am able to change the color of all entities within a block (without exploding the block), what is the problem in exploding those entities ?