I've been working in Maxscript for about 3 months now, so I am fairly new, and i recently came across the ability to execute strings inside of ms files like so:
str = "print \"hello\""
execute str
The Max Listener would then output "hello", as you might expect. i'm trying to use this functionality to create a dynamic rollout that creates a button for every parameter linked to a RailClone object in my scene. The RailClone object isn't important to the question, so I'm pretty sure you shouldn't need to know anything about it to help.
Anyway, here is my code:
--create an array of button names
btn_names = for p in obj.paname collect ("btn_" + p as string)
str = "group \"Custom Parameters\" \n(\n"
print btn_names
for p in 1 to btn_names.count do
(
str += "button " + btn_names[p] + "\n"
str += "on " + btn_names[p] + " pressed do\n"
str += "try\n(\n" + "\tprint \"hello test\"\n"
str += ")\n" + "catch(messageBox \"Script failed\")\n"
)
str += ")\n"
str = "print \"hello\""
print str
execute str
The first line grabs all of the object's parameters, but it just ends up being an array of strings. My issue occurs on the execute line, and the output is:
MAXScript Rollout Handler Exception: -- Runtime error: group() requires a node or node collection, got: "Custom Parameters" <<
As far as I know, all of my formatting is correct, so is there something else I must do? I appreciate any and all help. Thank you.