View Full Version : Unknown Number of Buttons

11 November 2005, 12:56 PM
I need to create a window which contains a certain number of buttons, which is specified by the user at runtime. Which means i need to specify the buttons in a for-loop. But it doesn't work, somehow Maya gets stuck in a endless loop when I'm running the Script.

global proc asfLoad(string $fName, int $skel)
string $rButNames[];
int $skelNum;
for($i = 1; $i <= $skel; $i++)
if ( $fName == "" )
$fName = `fileDialog -directoryMask "/carp/motion/hom/*.ASF"`;

// Need to check for valid file use may have selected cancel
// Open the file for reading
if ( $fName == "" )
print "No file selected";
$rButNames[$i] = $fName;
$fName = "";
if (`window -exists asfLoader`)
deleteUI asfLoader;
if (`window -exists amcLoader`)
deleteUI amcLoader;
window -width 160 -height 80 -rtf true -title "AMC Loader" amcLoader;
columnLayout ColumnLayout2;
frameLayout -labelVisible false -marginWidth 5 -marginHeight 5 rButFrame;
setParent rButFrame;
columnLayout rButCol;
setParent rButCol;
string $rButName[];
string $radioButton[];
radioCollection skelSelection;
for($j = 1; $j >= $skel; $j++)
$rButName[$j] = ("radioButton" + $j);
$radioButton[$j] = `radioButton -label $rButNames[$j] $rButName[$j]`;
setParent ColumnLayout2;
button -label "LOAD" -command "amcLoad $skelNum" loadButton;
showWindow amcLoader;

this is the part of the script I'm talking about.
The green part is where it loads the *.ASF files and saves the path's in $rButNames, so i can display them, in the new selection window I want to create. That part works perfect. $skel gives the number of ASF's to load that was selected by the User in the first window.

The Yellow part seems allright (at least it works, if get rid of the red part in the script).

The red-marked for-loop is where i wanted to create a radiobutton for each loaded ASF, labeled with the path of the corresponding ASF and named radioButton1, radioButton2, ... .
But with that loop in the script, Maya simply stops doing anything after it loaded the last ASF.

Since I'm new to Maya and Mel, and not a native english speaking guy, I'm pretty much at the end of my capabilities to solve that problem. I hope you guys are able to understand my problem in the first place and, more important, cabn help me out with some good advice at this.



11 November 2005, 04:24 PM
for($j = 1; $j <= $skel; $j++)
$rButName[$j] = ("radioButton" + $j);
$radioButton[$j] = `radioButton -label $rButNames[$j] $rButName[$j]`;

CGTalk Moderation
11 November 2005, 04:24 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.