Bounding Box returns wrong Z (blue) coordinate


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):

require 'sketchup.rb'
sf_model  = Sketchup.active_model
sf_defns  = sf_model.definitions
sf_layers = sf_model.layers

sf_defns.each{ |sf_def|
  sf_def.instances.each{ |sf_inst|
    if (  (sf_inst.layer.visible? == true) && (sf_inst.visible? == true) )
      puts sf_inst.bounds.min
      puts sf_inst.bounds.max

Result should be ( or expected to be):
(520cm, -0cm,0cm)
(580cm, 20cm, 20cm)

Actual result is:
(520cm, -0cm, -915,6cm)
(580cm, 20cm, -895,6cm)

I can not find the problem for several hours.

bb-test.skp (405.5 KB)


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.

Edit: The model’s axes have been moved too.

Utilizing the Axes Class with the API

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.

Which one is the correct?


I found the answer with your help!

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.

For an example of resolving the points of the visual boundingbox, have a look at this old extension of mine:


Thanks a lot! I have learned a lot from your extension and browsed others on your page. Your site is a very valuable source of knowledge.


Unless the parent is open for editing. Then all coordinates are in the global coordinate system, and I think bounding boxes are too.


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.)

Utilizing the Axes Class with the API

Hmm… yea, might be worth double-checking.


I’ve just double checked and the bounding box returned by bounds depend on the active drawing context.


Yes, but applying theses coordinates to the active context should still render the boundingbox correctly.


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.