ScriptExample to get polysurface centroid

Hi all,
Could you pleas send me a Code example of using the [VolumeMassProperties.Centroid Property] in Rhino common pleas. I am trying to get the centroid of boundingbox that I have generated using rehinoscriptsyntax like this:

for i in ListGuids:
BoBox = rs.BoundingBox(i)
BoBox = rs.coercebrep(BoBox, False)
BoundingBrep = rs.coercebrep(BoundingGeo, False)
#massprop = rs.SurfaceVolume(BoundingBrep)

poCen = R.Geometry.VolumeMassProperties.Centroid(BoBox)

but it doesnt seem Right.


Well, the “centroid” of a bounding box - if it’s a regular box - is just the midpoint of the diagonal. Much easier/faster than invoking mass properties…

BoBox = rs.BoundingBox(i)
ctr_pt=(BoBox[0] + BoBox[6])/2
1 Like