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?
dezmo
2
The #explode method is used to explode the component instance into separate entities.
Returns:
So you just need to pass it to selection…
An array of entity objects if successful, false if unsuccessful
Selection#add-instance_method
Sketchup.active_model.selection.add( instance.explode )
or similar for groups:
Sketchup.active_model.selection.add( group.explode )
2 Likes
Almost right, but Selection#add
throws a fit if the passed array has any Loop
or EdgeUse
objects, which #explode
does return.
The Selection#add
method’s error message is a bit misleading because loops and edge use objects are Sketchup::Entity
subclass objects. Viz:
Sketchup.active_model.selection.add(grp.explode)
Error: #<TypeError: wrong argument type (expected Sketchup::Entity or Array of
Sketchup::Entity)>
<main>:in `add'
The #add
method actually wants Sketchup::Drawingelement
subclass objects, so we must filter other types out …
stuff = instance.explode.grep(Sketchup::Drawingelement)
Sketchup.active_model.selection.add(stuff)
Logged issue:
2 Likes