# How do you measure the volume of a mesh?

Is there a function in blender to measure the volume of the mesh that you input in the geometry nodes? For example let's say I have a cube with the dimensions (10,10,10), then it should output 1000.0 because that is the volume of the cube.

• Hello and welcome! No, unfortunately this functionality does not currently exist. With a simple geometric shape it could be calculated (for example in case of a cube), but for more complex meshes there is no built-in way here. Dec 27, 2022 at 18:24
• When I've wanted to do this (actually, I wanted to find the center of gravity of a mesh, something slightly different) I've boolean'd it with a bunch of cubes, then counted the number of cubes in the output (which you can do by scaling along individual origins to 0, merging by distance, and then reading the statistics.) But that's a sampled solution; you probably want to see analytic solutions like discussed at blender.stackexchange.com/questions/63113/… . Dec 27, 2022 at 18:29

Using Blender 3.4's topology nodes and recreating this answer will give you the volume of a mesh.

public float SignedVolumeOfTriangle(Vector p1, Vector p2, Vector p3) {
var v321 = p3.X*p2.Y*p1.Z;
var v231 = p2.X*p3.Y*p1.Z;
var v312 = p3.X*p1.Y*p2.Z;
var v132 = p1.X*p3.Y*p2.Z;
var v213 = p2.X*p1.Y*p3.Z;
var v123 = p1.X*p2.Y*p3.Z;
return (1.0f/6.0f)*(-v321 + v231 + v312 - v132 - v213 + v123);
}
public float VolumeOfMesh(Mesh mesh) {
var vols = from t in mesh.Triangles
select SignedVolumeOfTriangle(t.P1, t.P2, t.P3);
return Math.Abs(vols.Sum());
}


The above code recreated in nodes:

Apologies for the spaghetti, Blend file is attached so no one has to recreate it.

You can check the results by enabling and using the built-in "3D-Print Toolbox" addon.

• Very nice and efficient approach. Dec 31, 2022 at 6:41
• This is awesome ! I would just replace the "Points Count" output type to Float instead of Integer so that you don't lose on precision. Jan 2, 2023 at 8:43

There is at list a possibility of volume calculation but it’s painfully slow, you have to stop the calculation on the last frame so it’s not very practical, furthermore it doesn't work with moving objects.

It’s based on the buffer hack. At every frame it increment the Z position of a plane accordingly to the index and with a Mesh Boolean it calculate the surface of this cross section of the mesh. Then the mesh section is instanced and the surface is stored in a Store Attribute node.

At the end, after the buffer hack, a Statistic Attribute calculate the mean of all the surfaces (except the first and the last witch are those of tangent planes and cause problem with the boolean, any way there surfaces is equal to 0), multiply it by the height and this volume value is stored too.

You have to set the definition by setting the Start Frame and the End Frame with a Driver. I hope it will help somebody one day...

You can use rigid body ops.

bpy.ops.rigidbody.object_add()
bpy.ops.rigidbody.mass_calculate(material='Custom', density=1) # density in kg/m^3
volume = ob.rigid_body.mass


https://blender.stackexchange.com/a/304033/72020