Grab objects in a selection set resulting from vla-explode

Grab objects in a selection set resulting from vla-explode

rajeshpatnaik2001
Advocate Advocate
424 Views
3 Replies
Message 1 of 4

Grab objects in a selection set resulting from vla-explode

rajeshpatnaik2001
Advocate
Advocate

Hi,

(ssget "_P") selects the objects resulting from (command "._Explode" entity).
But it is not selecting objects resulting from (vla-explode obj).

(ssget "_P") returns nil.

 

How to grab all the objects in a selection set resulting from (vla-explode obj)?

0 Likes
Accepted solutions (1)
425 Views
3 Replies
Replies (3)
Message 2 of 4

Kent1Cooper
Consultant
Consultant
Accepted solution

The typical way would be to mark the last object in the drawing as a variable before doing the exploding, then after, march through with (entnext) as long as there continues to be a next entity, and add those things to a selection set.

Something like [untested]:

(setq
  elast (entlast)
  ss (ssadd); initially empty selection set
)
(vla-explode obj)
(while (setq elast (entnext elast))
  (ssadd elast ss)
)
Kent Cooper, AIA
Message 3 of 4

rajeshpatnaik2001
Advocate
Advocate

Thanks @ Kent Cooper 🙂

0 Likes
Message 4 of 4

ВeekeeCZ
Consultant
Consultant

Since the vla-explode method actually returns an array of exploded objects, you could use that. 

Not saying it's simpler... 

 

(defun c:Test ( / s)
  (setq s (ssadd))
  (mapcar '(lambda (e) (ssadd (vlax-vla-object->ename e) s))
	  (vlax-safearray->list (vlax-variant-value (vla-explode (vlax-ename->vla-object (car (entsel)))))))
  (sssetfirst nil s))