If you select a parent and explode it via Edit>Group>Explode or Right-click>Explode, the children are selected after the operation.
If you use parent.explode the children are not selected.
How would you go about having the children selected after parent.explode ?
Will I have to iterate into the parent and get the child names?
The #explode method is used to explode the component instance into separate entities.
So you just need to pass it to selection…
An array of entity objects if successful, false if unsuccessful
Sketchup.active_model.selection.add( instance.explode )
or similar for groups:
Sketchup.active_model.selection.add( group.explode )
Almost right, but
Selection#add throws a fit if the passed array has any
EdgeUse objects, which
#explode does return.
Selection#add method’s error message is a bit misleading because loops and edge use objects are
Sketchup::Entity subclass objects. Viz:
Error: #<TypeError: wrong argument type (expected Sketchup::Entity or Array of
#add method actually wants
Sketchup::Drawingelement subclass objects, so we must filter other types out …
stuff = instance.explode.grep(Sketchup::Drawingelement)