I recently had a similar problem. Are you sure you’re collecting nested components here:
def self.make_selected_instances_unique(selection)
selection.each do |entity|
if entity.is_a?(Sketchup::ComponentInstance) || entity.is_a?(Sketchup::Group)
make_entities_unique(entity.definition.entities)
end
end
end
Code I found over here can at least gathers entities:
When you adjust that as follows it should collect nested components:
def collect_components( ents )
a = []
ents.each { |e|
if e.is_a?( Sketchup::ComponentInstance )
a.concat( collect_components( e.definition.entities ))
a << e
elsif e.is_a?( Sketchup::Group )
a.concat( collect_components( e.definition.entities ))
end
}
a
end