//for quick testing...delete once developed
SelectAll;
delete;
sphere;
sphere;
SelectAll -shapes;
// a function called each time a checkbox is checked/unchecked
proc string[] getSelections (){
string $collectSelection[] = ls -sl;
return $collectSelection;
}
// a procedure to change the values based on user checkboxes
proc makeChanges (string $boxNumber, int $value, string $collectSelection[]){
if ($boxNumber == "castShadows") {
for ($each in $collectSelection)
{
setAttr ($each +".castsShadows") $value;
}
}
}
//deletes existing window
if (window -exists myWindow)
deleteUI myWindow;
//builds a new gui
window -title "My Window" -resizeToFitChildren true myWindow;
columnLayout -adjustableColumn true;
frameLayout -collapsable false -l "Maya Settings" -w 200;
columnLayout;
$box1 = checkBox -al "left" -value 1 -h 28 -l "castShadows" -w 200
-onCommand "checkBox -edit -value 1 $box1; getSelections; makeChanges ('castShadows', 1, $collectSelection[]);"
-offCommand "checkBox -edit -value 0 $box1; getSelections; makeChanges ('castShadows', 0, $collectSelection[]);";
//for quick testing return value...delete once developed
string $button1 = `button -al "center" -h 28 -l "Get Selected Objects" -w 120`;
setParent..;
setParent..;
//for quick testing return value...delete once developed
button -edit -command ("getSelections();") $button1;
showWindow myWindow;
myWindow is created...but un-checking the castShadows checkbox yields:
// Error: checkBox -edit -value 0 $box1; getSelections; makeChanges ('castShadows', 0, $collectSelection[]); //
// Error: Syntax error /
I'm learning as I go here but can't seem to resolve this error.
Thanks.