# Object Dimensions OnSelect Script

**URL:** <https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760>\
**Category:** Scripting\
**Tags:** windows\
**Created:** [February 28, 2024, 8:24am UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760 "2024-02-28T08:24:49Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![ska\_drivers](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ska_drivers/32/759398_2.png) [@ska\_drivers](https://discourse.mcneel.com/u/ska_drivers)\
**Post date:** [February 28, 2024, 8:24am UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/1 "2024-02-28T08:24:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [February 28, 2024, 8:34am UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/2 "2024-02-28T08:34:29Z")

</div>

Is that a feature request?

---

<div class="post-metadata">

**Author:** ![ska\_drivers](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ska_drivers/32/759398_2.png) [@ska\_drivers](https://discourse.mcneel.com/u/ska_drivers)\
**Post date:** [February 28, 2024, 10:52am UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/3 "2024-02-28T10:52:56Z")

</div>

![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/f/4/b/f4bc1b219227fddec06ec70232b5caec4c878fc8.png)

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.

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [February 28, 2024, 10:58am UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/4 "2024-02-28T10:58:30Z")

</div>

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…

> [@ska\_drivers](#):
>
> It could be a script.

[BoundingBoxWithSizeOnScreen.py](https://discourse.mcneel.com/uploads/short-url/h6SzTKLLcn9g6DvYsElIXZVeMlf.py) (4.8 KB)

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

---

<div class="post-metadata">

**Author:** ![ska\_drivers](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ska_drivers/32/759398_2.png) [@ska\_drivers](https://discourse.mcneel.com/u/ska_drivers)\
**Post date:** [February 28, 2024, 11:15am UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/5 "2024-02-28T11:15:38Z")

</div>

I have Boundingbox. Smallest Rectangle

[![](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/5/4/9/549f85ec973046af0a251c333cd98f5ccee717da.jpeg "Smallest Rectangle") ](https://www.youtube.com/watch?v=9Asl0XFE_Bs)

---

<div class="post-metadata">

**Author:** ![clement](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/clement/32/772979_2.png) [@clement](https://discourse.mcneel.com/u/clement)\
**Post date:** [March 1, 2024, 3:08am UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/6 "2024-03-01T03:08:03Z")

</div>

> [@ska\_drivers](#):
>
> This should be done without entering any commands. It may be a new feature. It could be a plugin. It could be a script.

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

[DimensionInfo.py](https://discourse.mcneel.com/uploads/short-url/939dJU28jxKXb3MfyYa6caxXGu4.py) (1.5 KB)

\_  
c.

---

<div class="post-metadata">

**Author:** ![ska\_drivers](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ska_drivers/32/759398_2.png) [@ska\_drivers](https://discourse.mcneel.com/u/ska_drivers)\
**Post date:** [March 1, 2024, 5:15am UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/7 "2024-03-01T05:15:21Z")

</div>

@clement

You are a king.

Thank You

---

<div class="post-metadata">

**Author:** ![ska\_drivers](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ska_drivers/32/759398_2.png) [@ska\_drivers](https://discourse.mcneel.com/u/ska_drivers)\
**Post date:** [March 1, 2024, 6:57am UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/8 "2024-03-01T06:57:35Z")

</div>

![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/c/4/4/c44dad6b332932a1415aa0bcec76354cc403f8c1.jpeg)  
 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/1/c/6/1c626783166583ed7181216b781baf8b65e41d35.png)

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

---

<div class="post-metadata">

**Author:** ![clement](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/clement/32/772979_2.png) [@clement](https://discourse.mcneel.com/u/clement)\
**Post date:** [March 1, 2024, 12:49pm UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/9 "2024-03-01T12:49:57Z")

</div>

Hi @ska_drivers, i guess it should be

`Bttm = bbox.Min.Z`

\_  
c.

---

<div class="post-metadata">

**Author:** ![ska\_drivers](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ska_drivers/32/759398_2.png) [@ska\_drivers](https://discourse.mcneel.com/u/ska_drivers)\
**Post date:** [March 1, 2024, 1:16pm UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/10 "2024-03-01T13:16:03Z")

</div>

It gives incorrect results.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/1/c/6/1c626783166583ed7181216b781baf8b65e41d35.png)

this is how i got the correct results

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/e/e/d/eed079c7fc1966feb6c4031e4a9c4800f893741b.png)

---

<div class="post-metadata">

**Author:** ![clement](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/clement/32/772979_2.png) [@clement](https://discourse.mcneel.com/u/clement)\
**Post date:** [March 1, 2024, 1:25pm UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/11 "2024-03-01T13:25:01Z")

</div>

Hi @ska_drivers,

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

![grafik](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/2/d/5/2d571badde18fc51b795b751f2b1a89fea9d90a3.jpeg)

`box.Min` is number 0

\_  
c.

---

<div class="post-metadata">

**Author:** ![ska\_drivers](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ska_drivers/32/759398_2.png) [@ska\_drivers](https://discourse.mcneel.com/u/ska_drivers)\
**Post date:** [March 1, 2024, 1:28pm UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/12 "2024-03-01T13:28:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![clement](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/clement/32/772979_2.png) [@clement](https://discourse.mcneel.com/u/clement)\
**Post date:** [March 1, 2024, 1:35pm UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/13 "2024-03-01T13:35:24Z")

</div>

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

```python
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.

---

<div class="post-metadata">

**Author:** ![clement](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/clement/32/772979_2.png) [@clement](https://discourse.mcneel.com/u/clement)\
**Post date:** [March 1, 2024, 1:44pm UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/14 "2024-03-01T13:44:56Z")

</div>

> [@ska\_drivers](#):
>
> It gave incorrect results in DX or DY values.

please post an example where it failed using:

```python
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.

---

<div class="post-metadata">

**Author:** ![ska\_drivers](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ska_drivers/32/759398_2.png) [@ska\_drivers](https://discourse.mcneel.com/u/ska_drivers)\
**Post date:** [March 1, 2024, 5:48pm UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/15 "2024-03-01T17:48:45Z")

</div>



---

<div class="post-metadata">

**Author:** ![clement](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/clement/32/772979_2.png) [@clement](https://discourse.mcneel.com/u/clement)\
**Post date:** [March 1, 2024, 5:53pm UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/16 "2024-03-01T17:53:01Z")

</div>

Please upload this curve so i can check.

thanks,  
c.

---

<div class="post-metadata">

**Author:** ![ska\_drivers](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ska_drivers/32/759398_2.png) [@ska\_drivers](https://discourse.mcneel.com/u/ska_drivers)\
**Post date:** [March 1, 2024, 6:04pm UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/17 "2024-03-01T18:04:28Z")

</div>

[DimTest.3dm](https://discourse.mcneel.com/uploads/short-url/aGhEkxkH0GO2qNqZlsg7bEFssRC.3dm) (63.7 KB)

---

<div class="post-metadata">

**Author:** ![clement](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/clement/32/772979_2.png) [@clement](https://discourse.mcneel.com/u/clement)\
**Post date:** [March 1, 2024, 6:09pm UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/18 "2024-03-01T18:09:04Z")

</div>

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

> [@ska\_drivers](#):
>
> ```auto
> 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)
> 
> ```

But it should be like this:

 ![grafik](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/b/0/e/b0ebe20bfe9daf1d7168955dbcd2c5881086932e.png)

thanks,  
c.

---

<div class="post-metadata">

**Author:** ![ska\_drivers](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ska_drivers/32/759398_2.png) [@ska\_drivers](https://discourse.mcneel.com/u/ska_drivers)\
**Post date:** [March 1, 2024, 6:31pm UTC](https://discourse.mcneel.com/t/object-dimensions-onselect-script/176760/19 "2024-03-01T18:31:12Z")

</div>

CLEMENT  
Thank you very much.
