Grasshopper Python - Get center point



I am not able to get my center point to the center of the bounding box.

20180914 00 problem get center (5.1 KB)

avX = mt.fsum([(pnt.X) for pnt in list])/len(list)


You could call the Center property directly on the BoundingBox.


Really?! Can you tell me how in python?

import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import math as mt

list = rs.BoundingBox(x)

#avX = mt.fsum([(pnt.X) for pnt in list])/len(list)
#avY = mt.fsum([(pnt.Y) for pnt in list])/len(list)
#avZ = mt.fsum([(pnt.Z) for pnt in list])/len(list)

center = rs.BoundingBox.Center(rs.AddBox(list))

Is it possible in python?


Indeed: (6.3 KB)


Thank you, you answered my question.

Do you know how to make from a BB a Brep?


You can call this method on the BB variable:


Thank you, I tried to implement that one, but I do not understand it (this is my first time using Rhinoceros code instead of rhinoscriptsyntax). (I found it earlier on, but did not know how.)

20180915 00 problem bbox to (5.9 KB)


There’s a lot of stuff going on there you do not need (the __main__ check, scriptcontext.doc bits etc). If you set your input typehints appropriately, you can simply call properties/methods on RhinoCommon objects directly like so: (5.8 KB)

I also called the Inflate method on the bounding box here, as a simpler alternative to scaling it (from your other thread on this topic).

I would suggest maybe going through some GHPython basics before going much further: