View Full Version : UI building - radio buttons and loop


j00ey
08 August 2007, 10:26 PM
I have a scene with 29 tubes with various attributes I want to be able to control with a UI. I'm using poly cubes as standins whilst I work out how to do it [hence the "tubes" and "cubes"...]

I'm looping through 1-29 to build the UI and most of it is working but I can't work out how to get my radio buttons to work... I've left in the 2 methods I thought most likely to work but neither is working...

if (`window -ex tubeCtrlWindow`)
deleteUI tubeCtrlWindow;

string $shader[] = {"whiteSSSG", "lightBlueSSSG", "darkBlueSSSG", "yellowSSSG"};
string $currentCube[];

for ($i = 1; $i < 30; $i ++)
{
$currentCube[$i] = ("pCube" + $i);
}

window -t "tube control" -wh 305 625 -in "tubeCtrl" tubeCtrlWindow;

scrollLayout;

columnLayout -bgc .2 .2 .2 -adj 1 mainColumn;

for ($i = 1; $i < 30; $i ++)
{

frameLayout -bs "in" -cl 1 -cll 1 -l ("tube" + $i) -parent mainColumn ("tubeFrame" + $i);

columnLayout -w 300 -h 100 -adj 1 -co left 5 ("tubeColumn" + $i);

attrFieldSliderGrp -min 0.5 -max 1 -adj 3 -cal 1 left -cw4 40 50 170 10 -l UPos
-at ("pCube" + $i + ".tx");
attrFieldSliderGrp -min 0 -max 5 -adj 3 -cal 1 left -cw4 40 50 170 10 -l Length
-at ("pCube" + $i + ".ty");
attrFieldSliderGrp -min 0 -max 5 -adj 3 -cal 1 left -cw4 40 50 170 10 -l Width
-at ("pCube" + $i + ".tz");

radioButtonGrp- nrb 4 -cw4 50 70 70 50
-la4 "white" "light blue" "dark blue" "yellow"
-en1 1 -en2 1 -en3 1 -en4 1
-cc1 "sets -e -forceElement $shader[0] (\"pCube\" + $i)"
-cc2 "sets -e -forceElement $shader[1] $currentCube[$i]"
-cc3 "sets -e -forceElement $shader[2] $currentCube[$i]"
-cc4 "sets -e -forceElement $shader[3] $currentCube[$i]";

setParent ..;

setParent ..;

}

showWindow tubeCtrlWindow;
;

can anyone tell me why it doesn't work? - the bit to look at is...

for ($i = 1; $i < 30; $i ++)
{

frameLayout -bs "in" -cl 1 -cll 1 -l ("tube" + $i) -parent mainColumn ("tubeFrame" + $i);

radioButtonGrp- nrb 4 -cw4 50 70 70 50
-la4 "white" "light blue" "dark blue" "yellow"
-en1 1 -en2 1 -en3 1 -en4 1
-cc1 "sets -e -forceElement $shader[0] (\"pCube\" + $i)"
-cc2 "sets -e -forceElement $shader[1] $currentCube[$i]"

[if you want to test it you need a scene with 29 polyCubes and 4 shading Grps called whiteSSSG, lightBlueSSSG, darkBlueSSSG, yellowSSSG]

thanks very much in advance
J

JackSMillenium
09 September 2007, 06:24 AM
The radioButtonGrp "cc" commands are failing because your variables aren't actually being substituted in the final command it's running. I.e., when the button is clicked, it's trying to run:
sets -e -forceElement $shader[0] ("pCube" + $i)
instead of trying to run:
sets -e -forceElement "whiteSSSG" "pCube1"

Here's what the code should look like instead:

radioButtonGrp -nrb 4 -cw4 50 70 70 50
-la4 "white" "light blue" "dark blue" "yellow"
-en1 1 -en2 1 -en3 1 -en4 1
-cc1 ("sets -e -forceElement "+$shader[0]+" "+$currentCube[$i])
-cc2 ("sets -e -forceElement "+$shader[1]+" "+$currentCube[$i])
-cc3 ("sets -e -forceElement "+$shader[2]+" "+$currentCube[$i])
-cc4 ("sets -e -forceElement "+$shader[3]+" "+$currentCube[$i]);


Of note, the "-" before "-nrb" was also placed wrong, but maya didn't seem to mind...

CGTalk Moderation
09 September 2007, 06:24 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.


1