ScriptSpot

Forum topic · Scripts Wanted

how to calculate volume...

By raiso3d · 2007-08-11

Description

hi..i was sorry, i looking for max script to calculate irregular shape volume..anybody has? i have used BM breaker and it has none shown the value of object volume..thanks.

Comments (2)

lantlant · 2013-06-17

I like this script :)

(No subject)

Martijn van Herk · 2007-08-14

Here's a function which should return the volume as shown in the Measure Utility.

(

fn calculateVolume obj =

(

local volume = 0.0

local objMesh = snapshotAsMesh obj

local objFaces = objMesh.numFaces
for f = 1 to objFaces do

(
v = getFace objMesh f

v1 = getVert objMesh v.x

v2 = getVert objMesh v.y

v3 = getVert objMesh v.z

volume += ((v2.y-v1.y)*(v3.z-v1.z)-(v2.z-v1.z)*(v3.y-v1.y))*(v1.x+v2.x+v3.x)

)
volume / 6.0

)

units.formatValue (calculateVolume $)

)

Cheers,

Martijn