Maxscript Help: how Assign Several Variables to undefined at once


#1

Hello Everyone any idea how to optimize this line of code where I need to switch several variables to “Undefine”?

I tried using a ‘For-loop’ but instead, setting the var to “undefined” uses the var value and fails.

Var1 = undefined
Var2 = undefined
Var3 = undefined
Var4 = undefined

ArryVars = (var1, var2, var3, var4)
For SetVars in ArryVars do SetVar = undefined
--------> THIS DOES NOT WORK

As always thanks for your help.


#2

var1 = var2 = var3 = var4 = undefined


#3

hmm… i knew the solution might be simple and I will be embarrassed thanks a lot @Klvnk


#4

I have another question what if you have a case like this…

renderers.current.option1 = undefined
renderers.current.option2 = undefined
renderers.current.option3 = undefined
renderers.current.option4 = undefined
renderers.current.option5 = undefined
renderers.current.option6 = undefined

where renderers.current is a constant but the options name change but the state its the same for all…

is there another clean way to do that?

Thanks


#5

use SetProperty function

for prop in #( #render_prop_1, #render_prop_2, #render_prop_3 ) do SetProperty renderers.current prop undefined

#6

Thanks, @Serejah exactly what I was looking for… Thank you SO much for your input and help.