I drew a simple textured box which I converted into a component.
I would now like to convert all the faces of this box into component:
mod = Sketchup.active_model sel = mod.selection ents = mod.active_entities mod.start_operation('Convert faces to components', true) sel.grep(Sketchup::ComponentInstance).each do |s| s.definition.entities.grep(Sketchup::Face).each do |f| grp = ents.add_group(f) inst = grp.to_component defn = inst.definition defn.invalidate_bounds defn.name = "Component#1" tr = inst.transformation pts = tr.origin s.definition.entities.add_instance(defn, pts) inst.erase! end end mod.commit_operation
This method works but there are still faces in my box which mix with the instances.
If I aunt delete the faces with “f.erase!” all faces even those of new instances will be deleted.
Do you know how to avoid this problem?
Thank you in advance for your help.