PDA

View Full Version : button command in loop


mrMotion
01-21-2004, 01:33 PM
Im going to make buttons that depends on a fileList. The button is to run a command that read's the content of the file and use it to translate a object. The command is "mrMotion_poseMove()" the arguments 0 - "number og files" is which file to read from. I have tested procedure manualy so I know it works, but the buttons from this loop does not work. I't seems to me that the arguments gets the same on all the buttons, and the argument is the 1 more than the highest possible.

How can I make this work?

for($buttonCounter = 0; $buttonCounter < size($fileText); $buttonCounter++)
{
button -label $poseFileList[$buttonCounter]
-command "mrMotion_poseMove($buttonCounter)";
}

kletterget
01-22-2004, 10:53 AM
Hi There

Have you tried using the eval() command?

So instead of writing this:
button -l $poseFileList[$buttonCounter] -c "mrMotion_poseMove($buttonCounter)";

You write this:
eval("button -l " + $poseFileList + "[" + $buttonCounter + "] -c \"mrMotion_poseMove(" + $buttonCounter +")\"";

The Maya docs explain the use of the eval command in a wishy washy technical way, but it really is super useful, and I use it nearly all the time when I want to run a command which contains variables which are not known until the actual code is run.

Just check that I've included the correct amount of brackets and so forth, but it should work fine.

CGTalk Moderation
01-17-2006, 05:00 AM
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.