ScriptSpot

Forum topic · General Scripting

Select object less than x size

By M0nkey · 2010-08-17

Description

Does anyone know of a script that will select objects smaller than x volume or size?

Comments (2)

M0nkey · 2010-08-18

Thank you Anubis!

Love your work

-- modified version of the

Anubis · 2010-08-17

-- modified version of the example function from the MxsHelp:
fn CalculateVolume obj = 
( 
	local Volume= 0.0
	local Center= [0.0, 0.0, 0.0]
	local theMesh = snapshotasmesh obj
	local numFaces = theMesh.numfaces
	for i = 1 to numFaces do
	(
		local Face= getFace theMesh i
		local vert2 = getVert theMesh Face.z
		local vert1 = getVert theMesh Face.y
		local vert0 = getVert theMesh Face.x
		local dV = Dot (Cross (vert1 - vert0) (vert2 - vert0)) vert0
		Volume+= dV
		Center+= (vert0 + vert1 + vert2) * dV
	)
	delete theMesh
	Volume /= 6
	Volume
)

volLimit = 33.0 -- set desired volume limit
-- end select...
select (for obj in geometry where CalculateVolume obj <= volLimit collect obj)