# 3D regular BoundingBox from python component

**URL:** <https://discourse.mcneel.com/t/3d-regular-boundingbox-from-python-component/109136>\
**Category:** Grasshopper Developer\
**Tags:** python, rhino6\
**Created:** [September 23, 2020, 8:55am UTC](https://discourse.mcneel.com/t/3d-regular-boundingbox-from-python-component/109136 "2020-09-23T08:55:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinborst1](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/martinborst1/32/607738_2.png) [@martinborst1](https://discourse.mcneel.com/u/martinborst1)\
**Post date:** [September 23, 2020, 8:55am UTC](https://discourse.mcneel.com/t/3d-regular-boundingbox-from-python-component/109136/1 "2020-09-23T08:55:13Z")

</div>

Hello,

I currently don’t understand on how to get the 3D Bounding Box of a component.  
I’m sorry for asking so much.

```python
import rhinoscriptsyntax as rs
import ghpythonlib as ghpy
import Grasshopper as gh
import Rhino

pt = rs.CreatePoint(0,0,0)

box = ghpy.components.BoundingBox(mesh,ghpy.components.XYPlane(pt))

#print(dir(box)) # <-- Is this a bug?
"""
Runtime error (TypeErrorException): unsupported operand type(s) for +: 'list' and 'Array[str]'

Traceback:
 line 81, in __dir__ , "\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\ghpythonlib\components.py"
 line 14, in script
"""

print(box.Volume)
print(box.Corner)
print(box.Properties)
print(box.sdfsdf)
# These all return Rhino.Geometry.Box, even when using nonsense attributes like in the last line.

```

I already checked the forum, but these posts didn’t really help me:  
This one is using pure grasshopper for the bounding box though:  
[https://discourse.mcneel.com/t/bounding-box-size/68060](https://discourse.mcneel.com/t/bounding-box-size/68060)  
This one is for the minimum bounding box, all I need is a regular one:  
[https://discourse.mcneel.com/t/minimum-oriented-bounding-box-implementation-in-grasshopper-python-script-node/64344](https://discourse.mcneel.com/t/minimum-oriented-bounding-box-implementation-in-grasshopper-python-script-node/64344)  
…

---

<div class="post-metadata">

**Author:** ![Willem](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/willem/32/773637_2.png) [@Willem](https://discourse.mcneel.com/u/Willem)\
**Post date:** [September 23, 2020, 7:50pm UTC](https://discourse.mcneel.com/t/3d-regular-boundingbox-from-python-component/109136/2 "2020-09-23T19:50:29Z")

</div>

Hi Martin

No problem in asking too much, that’s what this forum is for.

I changed this to grashopper category because you are using gh components. There you will have better chances of getting usefull help. Also try to attach en example gh file for easier reproduction of the issue.

-Willem

---

<div class="post-metadata">

**Author:** ![diff-arch](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/diff-arch/32/528268_2.png) [@diff-arch](https://discourse.mcneel.com/u/diff-arch)\
**Post date:** [September 27, 2020, 6:23am UTC](https://discourse.mcneel.com/t/3d-regular-boundingbox-from-python-component/109136/3 "2020-09-27T06:23:30Z")

</div>

Hi @martinborst1,

```python
import Rhino.Geometry as rg

pt = rg.Point3d(0, 0, 0) # or rg.Point2d.Origin (also creates a point at the origin)
bbox = mesh.GetBoundingBox(False) # or mesh.GetBoundingBox(True) for physical accuracy but slower

print bbox.Volume, bbox.MinimumCoordinate, bbox.MaximumCoordinate

```

I recon `mesh` refers to a component input? If so, you probably need to set its type hint to mesh!

Here are some links to the relevant reference pages, if you for instance want to look up some methods and/or attributes of the BoundingBox structure:

> **[Point3d Structure](https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_Geometry_Point3d.htm)**

  

> **[GeometryBase.GetBoundingBox Method (Boolean)](https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_GeometryBase_GetBoundingBox_3.htm)**

  

> **[BoundingBox Structure](https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_Geometry_BoundingBox.htm)**

A structure, much like a class, is a data structure, a way to structure your code. In C# structures are stack allocated, which brings some performance benefits, compared to classes, which are all reference types and heap allocated. Heap allocated symbols need to be cleaned up when they run out of scope or are not needed anymore, and that’s were the garbage collector comes in. If you allocated lots of objects in heap memory, the garbage collector probably also has a lot of work to do and this entails a performance penalty, but that’s an other story really.

Honestly, I’d forget about node in code. Theoretically, it’s a nice concept, but also pretty much redundant. Use rhinoscriptsyntax or even better the API (aka RhinoCommon), like I do above.  
If you have questions, just ask here or in the Scripting forum!
