ScriptSpot

Forum topic · General Scripting

Repeat Script delete

By Mrjacks2o · 2022-01-06

Description

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 (4)

.

miauu · 2022-01-13




(
	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 · 2022-01-06


(
	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 · 2022-01-13

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?

Try this

obaida · 2022-01-19


(
	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"
)