PDA

View Full Version : apply command to multiple variables?


Geuse
04-29-2009, 10:26 PM
Hi, I'm building a UI for a leg rig and I have a bunch of textfields which I want to control the -enable state with a radioButtonGrp. Problem is, I don't know how to write it. I want to add all the rest of the textFields to the command so that this get's executed alltogether. I'm figuring on writing a for loop.

I was thinking along these lines:
First decaliring this variable at the top along with all the names of my variables stored in this bigger one.
string $allTxtFields[] = $hipFKTxtField $kneeFKTxtField $ankleFKTxtField $ballFKTxtField $footIKTxtField $poleVTxtField;
But even I can see this won't work.

I need some way to count them for processing inside a for loop. and then execute the same command on each. As of now I'm only enable to execute the command on one of the textfields.

radioButtonGrp
-numberOfRadioButtons 2 -cw3 170 60 60
-label " Click to use custom controls"
-labelArray2 "Yes" "No"
-columnAlign 1 left
-sl 2
-onCommand1("textFieldButtonGrp -e -en 1 $hipFKTxtField")
-offCommand1("textFieldButtonGrp -e -en 0 $hipFKTxtField")

mlefevre
04-30-2009, 01:29 PM
Hey,

Perhaps this can work.



if (`window -exists myWin`)
deleteUI myWin;

window
myWin;

columnLayout
myCol;

string $on = "textField -e -en 1 textField01;" + "textField -e -en 1 textField02;" + "textField -e -en 1 textField03;";
string $off = "textField -e -en 0 textField01;" + "textField -e -en 0 textField02;" + "textField -e -en 0 textField03;";

radioButtonGrp
-numberOfRadioButtons 2
-cw2 60 60
-labelArray2 "Yes" "No"
-select 1
-onCommand1 $on
-offCommand1 $off
myRBG;

textField
textField01;

textField
textField02;

textField
textField03;

showWindow myWin;


Good Luck!

Geuse
04-30-2009, 03:35 PM
Wee, thanks alot man!
have no time to check it out now though, gotta go.

Ah, you're the one that made the animatik rig! sweet, really dig that one!
thanks and keep it up!

Geuse
05-01-2009, 04:32 PM
I just wanted to thank you once more. Works really well.
I have encountered another problem though. Now as the UI is finished I'll start with the real code, but I'm not sure how to go about it. I thought of having the setup procedure global and in a separate file so once called from the UI it will search through the text in the textFields.

I just tried to write a basic to get started, but all I get is an error =/

From the UI I have the following button
//BUTTON
button
-bgc 0.55 0.4 1
-l "Setup Leg"
-h 30

-c ("dagSetupLeg");

and this is the setup procedure

global proc dagSetupLeg()
{

string $hipjoint = `textFieldButtonGrp -q -tx $hipTxtField`;
print $hipjoint;
}

$hipTxtField is the variable containing the name for the first textfield in the UI.

mlefevre
05-01-2009, 04:47 PM
It could be a number of problems.
Perhaps you have built a textField in the GUI, but in your procedure you are querying a 'textFieldButtonGrp' and not a 'textField'.
What exactly is the error?

In the example below, I give the textField it's own name, then refer to it directly in the procedure. Variables are a good way to go aswell though.

if(`window -exists myWin`)
deleteUI myWin;

window
-sizeable true
-width 200
myWin;

columnLayout
myCol;

textField
myTextField;

button
-bgc 0.55 0.4 1
-l "Setup Leg"
-h 30
-c "dagSetupLeg()"
myButton;

showWindow myWin;

global proc dagSetupLeg()
{
string $hipjoint = `textField -q -tx myTextField`;
print $hipjoint;
}


Good luck!

Geuse
05-01-2009, 08:23 PM
Thanks!

This is the code.


string $hipTxtField;
string $ButtonCommand[] = `ls -sl`;
string $jointName = $ButtonCommand[0];

$hipTxtField = `textFieldButtonGrp
-adj 2
-label "Specify Hip joint"
-text $jointName
-buttonLabel "set"`;

textFieldButtonGrp -e -tx "" $hipTxtField;
string $cmd = "string $sel[] = `ls -sl`;";
$cmd += "if (size($sel))";
$cmd += " textFieldButtonGrp -e -text $sel[0] " + $hipTxtField +";";

textFieldButtonGrp

-edit -buttonCommand $cmd $hipTxtField;

and when pressing the button to run the setupLeg procedure, I get this:
Error: "$hipTxtField" is an undeclared variable.

CGTalk Moderation
05-01-2009, 08:23 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.