Object volume calculation???????

A brazilian user asked to me if is possible to calculate the physical volume of an object. His enterprise uses a software named unigrapichs nx, which is very expensive, to calculate volumes of bottles. Is there a script that does it? Or is possible to do it with Python?

its possible to do pretty much everything witht he right calculations, python could do it but you’d need to get the equations to do it, i don’t know them but i wouldn’t be surprised if they wern’t simmilar to calculating cylidrical volume


It’s actually possible, once the proper script for it has been built. However, there are limitations. It’s probably trivial to calculate the volume of a mesh composed of polygons, you define a vertex inside it , and calculate the volume of each of the irregular tetrahedrons defined between each of the faces and the vertex. Then you sum up all the volumes calculated. This will work fine for most simple shapes, but will fail miserably if the mesh has a complex shape, like holes through it or a bent bottleneck. Essentially you need the reference vertex to have a clear line of sight to each of the other vertices of the mesh. You can get around this problem by splitting the mesh in more meshes, and then calculating the volume for each of these and summing the lot. If you want to obtain the same result for a mesh built up of NURBS, metaballs, subsurfaces or other geometrical contructs the calculations become much more complex, probably involving some sort of integration, and really way over my head. Also I don’t really know how to check if a vertex is within or outside a mesh.

The problem is way complex indeed.

If object is a body of revolution (BoR) then volume is trivial, once you 've got the area of the spinned section, which is a complex 2D problem, complex, but 2D

In 3D The only thing I can suggest you is the Brute Force ™ approach.

1 - Get Object Bounding Box

2 - Subdivide Bounding Box in a regular way, with smaller bricks

3 - Decide for any brick if it is inside or not

4 - Volume is volume of brick times number of bricks inside

5 - Repeat with finer (smaller) bricks untill difference between two following step is negligible