I need the corner points of the bounding box of a simple component.
The bounds.min and bounds.max returns the first two coordinates right,
but the third (blue) coordinate value is far shifted.
I enclose the model that I used for testing.
There is only one component , no Group, no nesting.
Here is the code (the real code is much longer, I have shortened it
for testing purpose):
The component has a translation applied. If you open the component for editing and reset the axes, you’ll see that the component’s origin is 915.6cm below the origin.
Thanks a lot! It was already a great help !
But something is still not clear for me:
Is this transformation related to the model or to the component?
The fact that I can see this translation if I edit the component,
tells me it should be realted to the compontent.
However, I insert that component from a file, so the component should be the same always.
If I insert the exact same component into a new model,
then everything looks OK.
This tells me the opposite: somehow the model and the axes are shifted along the blue axes somehow.
If I reset the axes to original state, then I see the my model was really shifted along the blue axes.
If I shift the entire model to the origin of the reseted axes, everything is OK.
Once again: thank you very much for your Quick help! Case is solved.
Note that Geom::BoundingBox is not the same as the visual boundingbox you see in the viewport. The bounds of an entity will always be relative to it’s parent.
In reality, the model’s axis and origin (ie the “global” axis) cannot be moved in SketchUp.
They are set to the global constants ORIGIN, X_AXIS, Y_AXIS and Z_AXIS.
What you may refer to (being moved) is the “drawing axis”, which is a user coordinate system similar to AutoCAD’s UCS. It affects how SketchUp’s native tools work, and any Ruby tool that takes it into account since it’s properties were exposed to the Ruby API with the 2016 release.
This means that the setting for the drawing axis does not affect Ruby coordinates unless the Ruby code chooses to honor it’s settings. All coordinates (outside group or components) are relative to the unchangeable global origin and axis. (This is why the component origin seemed to be way off.)
Normally it doesn’t matter much whether global coordinates or local coordinates are used, since both the methods returning coordinates and those taking coordinates are consistent to each other. With this however I think you could get strange coordinates if the local and global axes don’t line up. With the bounding box rotated differently you get different height, width, depth and diagonal measurements as well as different corners.