Repeat Script delete

This is my script..
It merges all the Objects Named "Box03" in All the Max files within that folder.

Then plays an actions for each object it merged sometimes it can merge up to 50 objects how can i make it repeat the Action field for each object that it merged named "Box03" before it Prints "done"

thanks in Advance

mergeObj = #("Box03")
files = GetFiles "C:/Users/Workstation\Desktop\AdScript/*.max"
for f in files do
MergeMaxFile f mergeObj

--Action field--
-----------------------------------------------------------
select $Box03
$.wirecolor = color 138 8 110
$.primaryVisibility = on
max quick render
delete $
-----------------------------------------------------------
Print "Done"

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

(
	mergeObj = #("Box03")
	files = GetFiles "C:/Users/Workstation\Desktop\AdScript/*.max"
	for f in files do
	MergeMaxFile f mergeObj
 
	--Action field--
	-----------------------------------------------------------
        objsArr = for o in objects where o.name == "Box03" collect o
	for i = objsArr .count to 1 by -1 do
	(
		objsArr[i].wirecolor = color 138 8 110
		objsArr[i].primaryVisibility = on
		max quick render
		delete objsArr[i]
	)
	-----------------------------------------------------------
	Print "Done"
)
miauu's picture

.

(
	mergeObj = #("Box03")
	files = GetFiles "C:/Users/Workstation\Desktop\AdScript/*.max"
	for f in files do
	MergeMaxFile f mergeObj
 
	--Action field--
	-----------------------------------------------------------
	for o in objects where o.name == "Box03" do
	(
		o.wirecolor = color 138 8 110
		o.primaryVisibility = on
		max quick render
		delete o
	)
	-----------------------------------------------------------
	Print "Done"
)
Mrjacks2o's picture

Thank you

Thank you.
Only Problem when it gets to delete o it doesn't loop it stops after it deletes.
But when i remove delete o it loops all actions.

what can cause delete to make the loop stop?

obaida's picture

Try this

(
	mergeObj = #("Box03")
	files = GetFiles "C:\\Users\\Workstation\\Desktop\\AdScript\\*.max"
	for f in files do (
         	if (MergeMaxFile f mergeObj) do (
	         	local o = getNodeByName  "Box03"
	        	o.wirecolor = color 138 8 110
	           	o.primaryVisibility = on
	        	max quick render
	        	delete o
        	)
	)
	-----------------------------------------------------------
	Print "Done"
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.