Developer: RhinoScript
Summary: Demonstrates how to calculate the volume centroid of a mesh.
I notice that Rhino's VolumeCentroid command only works on closed surfaces and polysurfaces. Is there a way I can calculate the volume centroid of meshes?
The following script will calculate the volume centroid of a mesh.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' MeshVolumeCentroid.rvb -- July 2009 ' Mary Fugier, Robert McNeel & Associates ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Option Explicit ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Calculates the volume centroid of a mesh object. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Sub MeshVolumeCentroid() Const RHINO_MESH = 32 Dim strObject, arrCentroid strObject = Rhino.GetObject("Select mesh for volume centroid calculation", RHINO_MESH) If Not IsNull(strObject) Then arrCentroid = Rhino.MeshVolumeCentroid(strObject) If IsArray(arrCentroid) Then Call Rhino.AddPoint(arrCentroid) Call Rhino.Print("Volume Centroid = " & Rhino.Pt2Str(arrCentroid)) End If End If End Sub ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' If dragged and dropped on Rhino, a "MeshVolumeCentroid" alias ' will be created. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Rhino.AddStartupScript Rhino.LastLoadedScriptFile Rhino.AddAlias "MeshVolumeCentroid", "_NoEcho _-RunScript (MeshVolumeCentroid)"