# Measuing an irregular volume from an .stl mesh

I am trying to measure the volume of an irregular object (e.g. a mold of clay) on either a concave or convex surface (such as the back of a hand).

The file is .stl and is a non-solid mesh.

I know that Blender comes with 3D printing tools to take these measurements but I am having problems making the object solid (taking into account the curvature of the surface) to take this volume.

Unfortunately, the surface cannot be scanned alone beforehand to subtract from the surface+clay image.

The ultimate dream is to write a python script to take a user defined area (e.g. the borders of the clay mold) and somehow measure the volume taking the curved surface into account. But at the moment, any advice on how to go about this with blender would be great.

EDIT: Here are some images of the file and what I am trying to achieve. I am trying to measure the indented suface in the 2nd image, taking into account the curvature shown by the side on profile in image 1. (Thanks).

• What do you exacltly mean by saying "non solid mesh"? May you post an image of the .stl? Till the mesh is watertight there should be no issue with the curvature in volume calculation. – Carlo Aug 25 '15 at 22:30
• Hi Carlo - thanks for your comment - I have uploaded some images to try and clarify the point. Sorry if any terms I am using are unclear. Thanks for your help. – Cato Sep 6 '15 at 21:19
• To get the volume of a mesh you'll need to define a closed surface. Cut away the parts of the surface that you are not interest in and close the holes with faces (you can remove them after the calculation). Than use the script below or the dedicated button in the 3D print toolbox add-on. If it doesn't work, maybe your mesh has some peculiarities that we can't see from the screenshot. In this case, I'll suggest to uplad it to blend-exchange.giantcowfilms.com so we can inspect it deeply – Carlo Sep 6 '15 at 22:25

The quick and dirty way would be this:

1. First use a remesh modifier with a fairly high number of iterations (at least 7), to keep a the fidelity high. The remesh modifier will automatically close off your mesh and make it watertight.

2. Use bmesh to calculate the volume:

import bpy, bmesh

o = bpy.context.object

remesh = o.modifiers[ len( o.modifiers ) - 1 ]
remesh.mode         = 'SMOOTH'   # Remesh type smooth
remesh.octree_depth = 7          # 7 subdivision levels

d   = o.to_mesh() # Create a temporary mesh with modifiers applied
bm  = bmesh.from_edit_mesh( d )
vol = bm.calc_volume()

• Even easier than the python script, enable the 3d printing toolbox addon and it has a button to calculate the volume. – sambler Aug 26 '15 at 4:19
• Actually that't true, if you don't want to use a script, just apply the remesh modifier and then use the 3D printing toolbox to get the volume. – TLousky Aug 26 '15 at 12:33
• Hi TLousky - many thanks for your post. In response to Carlo I have posted some images to try and clarify what I am trying to achieve. I need to somehow measure the indent shown in the 2nd image in my post alone. I tried seperating the clay mold as a seperate object then solidfying the clay object. I then "remeshed" the surface it was on, hoping it would repair the hole in the mesh and create a curved surface that I could then apply a Boolean to and end up with a solid mold of clay with a curved base. But this didn't work (the surface created with the remesh wasn't curved). – Cato Sep 6 '15 at 21:21
• Thanks also for using the code - ideally this is something that I want to keep as simple as possible. Which would allow people with very little computer experience to follow some simple steps. If there was a solution to make the whole process code and the user could just run the script, it would be ideal. – Cato Sep 6 '15 at 21:29
• If I run this , I am getting error "scene not specified" . d = o.to_mesh() in this line.please tell me what to do .@TLousky – kpdkps Mar 23 '16 at 6:10