I'm new here and I need help for my project. I try to get width, height and depth of my selected entities.
For example, this is my project's hierarchy:
- Code: Select all
model = Sketchup.active_model
selection = model.selection
selection.each do |entity|
UI.messagebox(entity.name)
entity.entities.each do |sub_entity|
UI.messagebox(sub_entity.name)
end
end
With this code, if I select A, I get the group A, 1 and 2. Now I'd like to get each group's dimensions. I tried this:
- Code: Select all
model = Sketchup.active_model
selection = model.selection
selection.each do |entity|
bb1 = Geom::BoundingBox.new
bb1.add(entity.bounds)
UI.messagebox("Name: #{entity.name}\nWidth: #{bb1.width}\nHeight: #{bb1.height}\nDepth: #{bb1.depth}")
entity.entities.each do |sub_entity|
bb2 = Geom::BoundingBox.new
bb2.add(sub_entity.bounds)
UI.messagebox("Name: #{sub_entity.name}\nWidth: #{bb2.width}\nHeight: #{bb2.height}\nDepth: #{bb2.depth}")
bb2.clear
end
bb1.clear
end
If I select the A group I get the right values for A but not for its subgroups 1 and 2.
If I select the subgroup 1, I get the right values for the subgroup 1.
If you can explain me why I get this, or tell me how to get what i want. I would appreciate.