Object Dimensions OnSelect Script

To see the dimensions of a clicked object without entering a command. Is it possible?

Select Object OnSelect Event
Rhino.StatusBarMessage Object.Width Height Length Debth

Is that a feature request?

When I click on an object, it should give 2D information of that object. This should be done without entering any commands. It may be a new feature. It could be a plugin. It could be a script.

I don’t know of anything that would automatically display this info in the status bar just by clicking on the object. That’s a lot of info there to display in a tiny area…

BoundingBoxWithSizeOnScreen.py (4.8 KB)

But you still have to click a button or type an alias to run the script on a selected object.

1 Like

I have Boundingbox. Smallest Rectangle

Hi @ska_drivers, you might try below script. Run it once to enable, run it again to stop:

DimensionInfo.py (1.5 KB)

_
c.

2 Likes

@clement

You are a king.

Thank You


Since I don’t know the language, I explained it with pictures.

Hi @ska_drivers, i guess it should be

Bttm = bbox.Min.Z

_
c.

It gives incorrect results.

this is how i got the correct results

Hi @ska_drivers,

it should give you the same Z since corners 0,1,2,3 are all at the same height.

grafik

box.Min is number 0

_
c.

It gave incorrect results in DX or DY values.

bbox = Rhino.Geometry.BoundingBox.Unset
for rh_obj in rh_objs: 
    bbox.Union(rh_obj.Geometry.GetBoundingBox(False))

x = abs(bbox.Max.X - bbox.Min.X)
y = abs(bbox.Max.Y - bbox.Min.Y)
z = abs(bbox.Max.Z - bbox.Min.Z)

I changed these lines

better not use rs methods in event delegates. You can see if this give the results you expect:

def MyDimensionInfoEvent(sender, e):
    rh_objs = list(scriptcontext.doc.Objects.GetSelectedObjects(False, False))
    if not rh_objs: 
        Rhino.UI.StatusBar.ClearMessagePane()
        return
    
    bbox = Rhino.Geometry.BoundingBox.Unset
    for rh_obj in rh_objs: 
        bbox.Union(rh_obj.Geometry.GetBoundingBox(True))
    
    x = bbox.PointAt(0,0,0).DistanceTo(bbox.PointAt(1,0,0))
    y = bbox.PointAt(0,0,0).DistanceTo(bbox.PointAt(0,1,0))
    z = bbox.PointAt(0,0,0).DistanceTo(bbox.PointAt(0,0,1))
    
    units = scriptcontext.doc.GetUnitSystemName(True, False, False, False)
    message = "DX={0:.3f}  DY={1:.3f}  DZ={2:.3f}  ({3})".format(x, y, z, units)
    Rhino.UI.StatusBar.SetMessagePane(message)

it will run slower of course. Try with millions of objects.

_
c.

1 Like

please post an example where it failed using:

x = abs(bbox.Max.X - bbox.Min.X)
y = abs(bbox.Max.Y - bbox.Min.Y)
z = abs(bbox.Max.Z - bbox.Min.Z)

_
c.

Please upload this curve so i can check.

thanks,
c.

DimTest.3dm (63.7 KB)

Hi, just download the script from above again. Somehow in your script you have:

But it should be like this:

grafik

thanks,
c.

1 Like

CLEMENT
Thank you very much.

1 Like