Python Script: Calculating the Volume of Objects

There are a few things to keep in mind:

  • Mesh must be triangulated (ctrl-t)
  • Mesh must me manifold
  • Must have normals pointing outside
  • Apply size and rotation before using (ctrl-a)

If you’re unfamiliar with running external Python scripts, here’s how to use it: open the Text Editor window and load the script into it. In the 3D window, select the object whose volume you want to calculate, then in the Text Editor window press ALT+R to run the script. The result will be displayed in the console:

term.png

OSX Users: if you need a console, you’ll need to start Blender from the commandline. Open a terminal and enter the following command:

/Applications/Blender/Blender.app/Contents/MacOS/blender

Further down the discussion, Yorik uses this script in another way: he has modified it so that it will spit out a bill of materials for his architectural projects. Quite clever – I wonder what else you could use it for :)

This script is still a little rough around the edges, for example it doesn’t handle object scaling well yet, and of course it could do with a nice GUI. Maybe someone is interested in improving it?

Advertisement