# Calculating Mesh Volume Centroid

Developer: RhinoScript
Summary: Demonstrates how to calculate the volume centroid of a mesh.

## Question

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.Print("Volume Centroid = " & Rhino.Pt2Str(arrCentroid))
End If
End If

End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' If dragged and dropped on Rhino, a "MeshVolumeCentroid" alias
' will be created.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''