ScriptSpot

Forum topic · General Scripting

Function no work

By jmpinero · 2014-08-30

Description

Hi, I build a function that reset all object in scene. This script write with "for o in objects do..." but reset some objects, not all objects. Why? 

 

clearlistener()

function resetMesh =

(

for o in objects do 

(

if (superclassof o) == geometryClass do

(

convertToPoly o

nm = (o.name as string)

n = convertToPoly (box name:nm wirecolor:black)

polyop.setFaceSelection n #all

n.EditablePoly.delete #Face

n.attach o n

setTransformLockFlags n #all

)

)

)

resetMesh ()

Comments (4)

Thanks U

jmpinero · 2014-09-04

Perfect! thank you :D

jmpinero · 2014-08-30

if I create six teapot, only reset four.
Why?

No reset all object of geometry class.

I try this function in 3ds max 2013 and 2015, and both cases the same result

.

miauu · 2014-09-02

The problem is, because you are using


for o in objects do

Use this:


(
	clearlistener()
	function resetMesh =
	(
		local poSetFaceSelection = polyop.setFaceSelection
		local objsArr = objects as array
		for o in objsArr where (superclassof o) == geometryClass do with undo off
		(
			convertToPoly o
			nm = (o.name as string)
			n = convertToPoly (box name:nm wirecolor:black)
			poSetFaceSelection n #all
			n.EditablePoly.delete #Face
			n.attach o n
			setTransformLockFlags n #all
		)
	)
	resetMesh ()
)

.

miauu · 2014-08-30

The objects that are not resets are?
Your functions works only with geometry objects, so the splines, helpers, lights will no the processed by the function.