[Closed] Convert string to maxobject?
Hi,
I am trying to set Render Elements (for Scanline, Vray, Mental Ray) via MaxScript. The general approach is that based on a given string (coming out of a .txt) a Render Element is set. I am currently doing this with a case statement for each and every single Render Element, which is very annoying.
Example:
for n in arProductionlayersVray do(
case n of(
"VRayTotalLighting": (
re.addrenderelement (VRayTotalLighting elementname:"VRayTotalLighting")
)
"VRayAlpha": (
re.addrenderelement (VRayAlpha elementname:"VRayAlpha")
)
...
Isn’t there a way to generalize this into one funtion? Something like:
n = "VRayTotalLighting"
re.addrenderelement (n elementname:(n as name))
?? I just couldn’t make it work to convert the string “VRayTotalLighting” to the required MaxObject VRayTotalLighting. I assume I am missing something easy?
Thanx,
Lena
ok…I thought you shouldn’t use it. I read on
http://www.scriptspot.com/3ds-max/tutorials/maxscript-coding-standards
“…quote by Larry Minton, If youre using execute() youre doing it wrong. “
But I guess I will just ignore that…
Well there are cases where you can’t avoid it, due to maxscript limitations.
You should try not to use it too often though.
For you and for what you want to do, it’s the right thing. It also means if you add additional elements, you don’t have to update your code, the execute method will pick it up.
It is, however, one of the slower functions in maxscript…
Shane