PDA

View Full Version : UI button execute proc w/ arguments?


KingCrizzo
12-02-2011, 07:49 PM
I'm having a hell of a time trying to figure out how I can get this button to execute my towerMaker proc using the values from the window. I believe the problem is with this line:

-c "towerMaker(theStacks, theSides, theRotation)";

How do I get it to grab the values from the sliders?

Full code:


global proc towerMaker(int $stack, int $sides, int $rotation) {

for ($i = 0; $i < $stack; $i++)

{

polyPipe -sa $sides -sc 2 -rcp on -r ($stack-$i) -t 2 -h 0.01; //creates each layer

rotate 0 ($i*$rotation) 0; //rotates amount specified

move 0 ($i*2) 0; //moves each iteration up one level

}

}

if(`window -exists newWindow`)

deleteUI newWindow;

window -title "TowerMaker" newWindow;

columnLayout;



intSliderGrp

-label "Stacks"

-value 25

-minValue 1

-maxValue 100

-field true theStacks;

intSliderGrp

-label "Sides"

-value 5

-minValue 3

-maxValue 20

-field true theSides;

intSliderGrp

-label "Rotation"

-value 10

-minValue 0

-maxValue 360

-field true theRotation;

button

-label "Execute"

-c "towerMaker(theStacks, theSides, theRotation)";



showWindow newWindow;

Keilun
12-02-2011, 08:21 PM
Since you've explicitly named your UI components, rather than feed it into the proc as an argument, just read it directly from those UI components inside your proc.

For example:


global proc towerMaker() {
int $stack = `intSliderGrp -q -v theStacks`;
int $sides = `intSliderGrp -q -v theSides`;
int $rotation = `intSlideGrp -q -v theRotation`;
//...
}


As soon as you try to build in the arguments into the command string itself, it's going to be static. So your best bet is to either uniquely name your UI components as you've done, or store the names of those components in global string vars for reference later.

If you know that the command that the button should execute can be static, then yeah you can build the string out, but it doesn't look applicable in this case.

KingCrizzo
12-02-2011, 08:34 PM
Smart. Thanks.

CGTalk Moderation
12-02-2011, 08:34 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.