I am working in a plug-in that requires exploding all group and components in the model. I wonder if it is possible to know before exploding the model, how many explode operations will be performed.
I have been using a code for that as follows:
defs = Sketchup.active_model.definitions count = 0 defs.each do |d| d.instances.each do |e| next unless (e.layer.visible?) if (e.is_a? Sketchup::Group) count += 1 elsif (e.is_a? Sketchup::ComponentInstance) count += 1 end # end if Group/ComponentInstance end # end loop on instances end # end loop on definitions
but it turns out that for some models this counting is less than the number of explode operations performed. For example the attached model contains nested groups/components, with the code above I count 57 but I can see the amount of explode operations is 70.
Houses_SU18.skp (69.8 KB)