hi, how can I get the Bounding Box center?
rs.BoundingBox returns a list of eight 3D points that define the bounding box, So you can compute the average of these points:
import rhinoscriptsyntax as rs from functools import reduce bbox = rs.BoundingBox(g) a = reduce(lambda a, b: a + b, bbox) / len(bbox)
using Rhino.Geometry.BoundingBox you can directly get the bounding box and it’s center like this:
bbox = g.GetBoundingBox(True) a = bbox.Center
BoundingBoxCenter.gh (4.9 KB)
Using BoundingBox.PointAt(0.5,0.5,0.5) would be another option
To add a slightly faster option: average just the min max points:
import rhinoscriptsyntax as rs bbox = rs.BoundingBox(g) a = (bbox + bbox) * 0.5
A lazy programmer, such as myself, might just use BoundingBox.Center.