Retrieve the size of bounding box of selection
-
Surely for a rotated instance the bb [
.bounds
] is read relative to the model's world axes [or it's container's axes??] ?
Clearly Rotating/Scaling a component-instance will change its individual bb, but itsdefinition
bb is always unchanged ?
So you can find one or the other depending on what is needed... -
@jim said:
I was thinking if the instance was rotated 90 deg. around Z, then x and y dimensions would be swapped, but that is a specific case.
But that's OK then, because AFTER the rotation, the x of the object's BB is "what it is" NOW regardless of was it was before. It IS the x dimension, at the time of the .x method call. And .height and .width would be swapped as well, correct ?
What I am wanting is a y method that returns the y dimension of the BB, at the time of call.
-
Nice all this but, i am new in ruby, how can i retrieve the size of all component... including sub-component?
` mod = Sketchup.active_model # Open model
ent = mod.active_entities # All entities in modelmessage = ""
ent.each { |e|
n = e.name
scale_x = ((Geom::Vector3d.new 1,0,0).transform! e.transformation).length
scale_y = ((Geom::Vector3d.new 0,1,0).transform! e.transformation).length
scale_z = ((Geom::Vector3d.new 0,0,1).transform! e.transformation).length
bb = nil
if e.is_a? Sketchup::Group
bb = Geom::BoundingBox.new
e.entities.each {|en| bb.add(en.bounds) }
elsif e.is_a? Sketchup::ComponentInstance
bb = e.definition.bounds
endif bb
dims = [ width = bb.depth * scale_x, height = bb.width * scale_y, depth = bb.height * scale_z ]
message = message + "Cabinet: " + n + "\nHeight: #{dims[0].to_l}\tWidth: #{dims[1].to_l}\tDepth: #{dims[2].to_l}"
end
}
UI.messagebox(message, MB_MULTILINE)`I would like to have dimensions of all pieces of the cabinet.
I know Cutlist. But i only need name of piece and dimensions.
And Cutlist script is to complicated for me.
Someone can help me with this? PLZ
Advertisement