How do I get object centroids? This returns zeros. I tried a bunch of things but still get zeros. I totally know it’s completely wrong, but I don’t know how to figure it out:
def get_volume_centroid(objref):
obj_type = objref.Object().ObjectType
brep = objref.Brep()
mesh = objref.Mesh()
if brep and brep.IsSolid:
mp = Rhino.Geometry.VolumeMassProperties.Compute(brep)
if mp:
VolCent = ("{0}".format(mp.Centroid))
return VolCent
elif mesh and mesh.IsSolid:
mp = Rhino.Geometry.VolumeMassProperties.Compute(mesh)
if mp:
VolCent = ("{0}".format(mp.Centroid))
return VolCent
else:
VolCent = 0
return VolCent
8 posts - 4 participants