29
$\begingroup$

How can I display volume of any mesh object?

I can display length of an edge, the area of the face, but nothing for volume. Is it possible?

$\endgroup$

5 Answers 5

31
$\begingroup$

You can use the 3D Print Toolbox add-on for that. Activate it in the Preferences and it will appear in the Tool Shelf of the 3D View. Top line buttons let you calculate volume and total area.

3D Print View

$\endgroup$
4
  • 1
    $\begingroup$ For me, the addon was called 3D Print Toolbox and you open it on the absolute left - there are vertical "tabs" Tools, Create, ...., 3D Print Toolbox (look below "File" menu) $\endgroup$
    – jave.web
    Commented Jul 10, 2019 at 17:06
  • $\begingroup$ How does this work in Blender 2.8? I don't see the menu. $\endgroup$ Commented Jan 24, 2020 at 6:56
  • $\begingroup$ Print3D add-on crashes blender in Ubuntu 20.04 (v2.28.7) but works if using v2.93.2 $\endgroup$ Commented Aug 17, 2021 at 0:28
  • $\begingroup$ Missing in Blender 4.1 :( $\endgroup$ Commented Aug 7 at 2:30
10
$\begingroup$

First activate the 3D-Print Toolbox addon: Edit > Preference >Add-ons and search 'print'. Now you can find the toolbox in the sidebar panel (press n if it does not show) Look in the 3D-print tab under statistics.

enter image description here

$\endgroup$
5
$\begingroup$

You don't need an addon for this.

In general, the methods for calculating the volume of a mesh can be divided into two categories: (1) Analytical methods which are based on mathematical formulas, these methods are efficient and accurate but are limited to simple shapes. (2) Numerical methods which involve breaking the mesh into smaller parts and summing the volume of those parts. These methods can be applied to any shape, but the accuracy of the results may vary depending on the number of parts used and the method for calculating the volume of each part.

Here's a script that uses the Numerical Method to calculate the volume of a mesh.

import bpy
import bmesh
from mathutils import Vector

obj = bpy.context.active_object
me = obj.data

bm = bmesh.new()
bm.from_mesh(me)
bm.transform(obj.matrix_world)
bmesh.ops.triangulate(bm, faces=bm.faces)

volume = 0
for f in bm.faces:
    v1 = f.verts[0].co
    v2 = f.verts[1].co
    v3 = f.verts[2].co
    volume += v1.dot(v2.cross(v3)) / 6

print("Volume:", volume)

bm.free()
$\endgroup$
4
  • 1
    $\begingroup$ This can also calculate the total volume of multiple separate meshes within an object, but take note that mesh overlapping is not taken into consideration and will still result in the sum of all mesh volumes regardless. $\endgroup$
    – Harry McKenzie
    Commented Jan 13, 2023 at 2:03
  • 2
    $\begingroup$ Very nice. I use this to find duplicate meshes with flipped normals and it works very well. $\endgroup$
    – relaxed
    Commented Sep 28, 2023 at 10:25
  • $\begingroup$ What is the unit of the computed volume? Edit: For a 1m x 1m x 1m cube I get a volume result of 1, and for a 2m x 2m x 2m I get a volume of 8, so that means that (at least in my case) the volume is in cubic meters (m³). I'm assuming it would follow whatever units you've configured your Blender scene for. $\endgroup$ Commented Aug 7 at 3:12
  • $\begingroup$ @aggregate1166877 yes exactly. $\endgroup$
    – Harry McKenzie
    Commented Aug 7 at 4:36
1
$\begingroup$

For performance reasons I came up with the following solution based on rigid body ops.

def select_object(ob):
    for o in bpy.context.selected_objects:
        o.select_set(False)
    ob.select_set(True)
    bpy.context.view_layer.objects.active = ob

def calc_object_volume(ob):
    select_object(ob)
    bpy.ops.rigidbody.object_add()
    bpy.ops.rigidbody.mass_calculate(material='Custom', density=1) # density in kg/m^3
    return ob.rigid_body.mass
$\endgroup$
0
$\begingroup$

If you want to display the volume inside the scene as an entity then you can use a very simple geometry node setup that is described in the following answer:

https://blender.stackexchange.com/a/325516/205751

Node setup:

node setup for calculating volume

Then you can get the volume output to a value to string and then use a string to curve node to display it in the scene.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .