Get Volume Centroid of Multiple Objects

Hi, I would like to take the volume centroids of lots of boxes (closed solid polysurfaces).

When I select all the boxes (hundreds of them) and use VolumeCentroid, it gives me the centroid of their grouped bounding box. I need the individual centroid of each object selected. It’s easy enough if I’m just selecting a few boxes but I need to do it for hundreds of them.

For example, I’ve got some boxes:

When I select them all and use volumeCentroid I get their combined centroid, not what I want.

This is the result I want, a centroid for each selected volume.

The reason I can’t do it box-by-box is I have a lot of boxes.

I’m not sure if I need .rvb or grasshopper for this. If I do, that’s fine, just please be specific because I don’t have any experience using them.

Thank you!

With so many objects, I’d use Grasshopper.

had this floating around

Option Explicit
'adds a Dot at the selected objects' centroid
'with the object volume in current file units

' Rhino.AddStartupScript Rhino.LastLoadedScriptFile
' Rhino.AddAlias "VolumeTag","_NoEcho _-Runscript (VolumeTag)"

Call VolumeTag()
Sub VolumeTag()

	Dim arrObj, strObj,  strVol, arrVolume, strVolume, arrCent, arr3dCent, arrThings, strDot, strGroup

	arrObj = Rhino.GetObjects("Select closed objects for volume tag", 8 + 16 + 32,, True)

	If IsArray(arrObj) Then

		For Each strObj In arrobj

			arrvolume = Null
			arrCent = Null
			arr3dCent = Null

			If Rhino.IsSurface(strObj) Or Rhino.isPolysurface(strObj) Then

				If Rhino.isObjectSolid(strObj) Then
					arrVolume = Rhino.SurfaceVolume(strObj)
					strVolume = Round(arrVolume(0), 4)
					arrCent = Rhino.SurfaceVolumeCentroid(strObj)
					arr3dCent = arrCent(0)
				End If

			ElseIf  Rhino.IsMesh(strObj) Then

				If Rhino.IsMeshClosed(strObj) Then
					arrVolume = Rhino.MeshVolume(strObj)
					strVolume = Round(arrVolume(1), 4)
					arr3dCent = Rhino.MeshAreaCentroid(strObj)
				End If

			End If

			If IsArray(arr3dCent) Then
				strDot = Rhino.AddTextDot("Vol = " & strVolume, arr3dCent)
				strgroup = Rhino.addGroup
				arrThings = array(strDot, strObj)
				Rhino.AddObjectsToGroup arrThings, strGroup
			End If


	End If

End Sub

My ‘laying around’ version - (549 Bytes)

To use the Python script use RunPythonScript, or a macro:

_-RunPythonScript "Full path to py file inside double-quotes"


Thank you Pascal! This is exactly what I needed.