ScriptSpot

Forum topic · Scripts Wanted

Simple Scripts wanted

By M0nkey · 2010-08-17

Description

Hi Guys,

I've been using scriptspot for years and have only signed up recently.

I have a problem, I have some very messy microstation models that I need to clean up for rendering. However, there are an insane amount of objects i need to clean up.

Can someone suggest a script/s that might do the following:

- select objects that are inside another objects bounding box

- delete objects less than x amount of size or volume

If anyone could point me in the right direction, would be very grateful.

Thanks

Comments (1)

(   local minVolume =

Graph · 2010-10-27


(

	local minVolume = 100
	
	fn CalcVolume obj = 
	( 
		local Volume= 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 
		) 

		delete theMesh

		Volume /= 6 
		return Volume
	)

	local deAll = #()
	
	for i in geometry where isValidNode o do
	(		
		for o in geometry where i != o AND isValidNode o do
		(
			if intersects i o AND CalcVolume obj < minVolume do append delArr o
		)
	)
	delete delArr
)