conponentInstance.definition.entities give a list of edge and face, but for the same component, the face size is not always the same
Its because of definition of component, but the component has been transformed
remorque latte bounds test.skp (4.5 MB)
class InfoSelectionObserver < Sketchup::SelectionObserver
def onSelectionBulkChange(selection)
putsInfoSelection(selection[0])
end
end
Sketchup.active_model.selection.add_observer(InfoSelectionObserver.new)
def putsInfoSelection(entities)
putsSizeEntity(entities)
if(entities.is_a?(Sketchup::ComponentInstance))
entity = entities.definition.entities
#scale_group_definition(entity)
elsif(entities.respond_to?(:each))
entity = entities
else
return
end
entity.each { | ent |
putsSizeEntity(ent)
}
end
def putsSizeEntity(entity)
if entity.respond_to?(:bounds)
bb = entity.bounds
geom = {
"d" => bb.depth.to_mm.round(),
"h" => bb.height.to_mm.round(),
"w" => bb.width.to_mm.round(),
}
puts "Size : #{entity.to_s} #{geom.to_s}"
else
puts "No size for : #{entity.to_s}"
end
end
With this code, when i select the component, and display infoSelection i have not the same size for the face surrounded
If i right click on this component and click on “Scale the definition” and select the same component, the same face give the right size
there is certainly a principle that I did not understand with sketchup, but I wonder how to always see the correct size of the faces when I select a component