Hi everyone, I’m a newbie to maxscript, I have something to ask about dropdownlists.
for example
rollout test "test"
(
dropdownlist test "test" items:#("A","B") height:6
button btn_test "get selection"
on test selected i do
(
print test.items[i]
)
on btn_test pressed do
(
print test.items[test.selection]
)
)
createdialog test
the question is, how does item “A” (actionMan.executeAction 0 “16” – File: New Scene, Clear All) perform if the “get selection” button is pressed?
and item “B” appears (actionMan.executeAction 0 “40010” – File: Import File) if “get selection” button is pressed?
generally anything you want a UI control to do should be defined as a separate function
and the control then calls the function . It’s been years since I used Max Script, but here is a basic script:
(
/*
first you define a function for each behavior
the commands for new file and open file actions are probably descibed under "MAX Commands" in the documentation
http://docs.autodesk.com/3DSMAX/15/ENU/MAXScript-Help/index.html?url=files/GUID-0B41CCC0-92AC-4005-B6D6-4ADACD82D39C.htm,topicNumber=d30e656790
*/
fn new_scene = (
print "action a: new file"
/* define the new scene behavior here*/
)
fn open_scene = (
print "action b: open file"
/* define the open file behavior here*/
)
rollout test "test"(
dropdownlist test "test" items:#("A","B") height:6
button btn_test "get selection"
on test selected i do
(
print test.items[i]
)
/* use if - then clauses to trigger the deisred fucntion*/
on btn_test pressed do
(
if test.items[test.selection] == "A" do open_scene()
if test.items[test.selection] == "B" do new_scene()
)
)
createdialog test
)
When I used Max Script , I tended to pack all my functions and UI for a tool into s single stuct, as described in this CG Talk thread Max Scritpt structs are very useful for grouping functions and data together and avoiding globals.