I am trying to control the width, height and depth of a poly cube then create the cube. My variables from the slider bars pass correctly but when I go to create the cube it does not get the updated width, height and depth variable. Any Ideas how to fix this problem? Here is what I have coded so far.
if ( (window -ex cubert) == true ) deleteUI cubert;
string $window = window -widthHeight 200 200 -title "Walt's Cube Maker" cubert; columnLayout -adj true;
//width, height and Depth variables
float $wth = 0;
float $hght = 0;
float $dpth = 0;
//get info from slider bars put into width, height and Depth variables
string $control = `floatSliderGrp -label "Width" -field true`;
string $cmd = ("$wth = `floatSliderGrp -query -value " + $control + "`");
floatSliderGrp -edit -dragCommand $cmd -changeCommand $cmd $control;
string $control1 = `floatSliderGrp -label "Height" -field true`;
string $cmd1 = ("$hght = `floatSliderGrp -query -value " + $control1 + "`");
floatSliderGrp -edit -dragCommand $cmd1 -changeCommand $cmd1 $control1;
string $control2 = `floatSliderGrp -label "depth" -field true`;
string $cmd2 = ("$dpth = `floatSliderGrp -query -value " + $control2 + "`");
floatSliderGrp -edit -dragCommand $cmd2 -changeCommand $cmd2 $control2;
//pass variables width, height and Depth into create string
string $create = "polyCube -w " + $wth + " -h " + $hght + " -d " + $dpth;
//create Cube button -label "Create" -align "center" -c $create;
showWindow $window;
Thanks for your help! Walt
yuya
February 2, 2001, 4:14am
2
In your script, you get value using this statement
string $cmd = ("$wth = floatSliderGrp -query -value " + $control + "");
But you should get value like this.
//pass variables width, height and Depth into create string
string $create = "polyCube -w (floatSliderGrp -q -v $control) -h (floatSliderGrp -q -v $control1) -d (floatSliderGrp -q -v $control2)";
If you change like this, I think following line is needless.
** string $cmd = ("$wth = floatSliderGrp -query -value " + $control + ""); floatSliderGrp -edit -dragCommand $cmd -changeCommand $cmd $control; **
** string $cmd1 = ("$hght = floatSliderGrp -query -value " + $control1 + ""); floatSliderGrp -edit -dragCommand $cmd1 -changeCommand $cmd1 $control1; **
** string $cmd2 = ("$dpth = floatSliderGrp -query -value " + $control2 + ""); floatSliderGrp -edit -dragCommand $cmd2 -changeCommand $cmd2 $control2; **
Hey thanks that helped alot. Here is what I am trying to do. I am making a GUI that will randomly duplicate an objects place, rotation and scale. Here is what I am a little confused on. Do I need to make a seperate mel script and just call it once I hit the duplicate button? If so, am I writing my mel correct? Here is what I have.
global proc radomdulicate(float rotcontrolx1; float $rotcontrolx2; float $rotcontroly1; float $rotcontroly2; float $rotcontrolz1; float $rotcontrolz2; float $movcontrolz2; float $movcontrolx1; float $movcontrolx2; float $movcontroly1; float $movcontroly1; float $movcontrolx2; float $sclcontrolz2; float $sclcontrolx1; float $sclcontrolx2; float $sclcontroly1; float $sclcontroly1; float $sclcontrolx2; string $looptimes;) { while ($loop <= $looptimes) { duplicate; rotate (rand ((floatSliderGrp -q -v $rotcontrolx1) ,(floatSliderGrp -q -v $rotcontrolx2))) (rand ((floatSliderGrp -q -v $rotcontroly1) ,(floatSliderGrp -q -v $rotcontroly2))) (rand ((floatSliderGrp -q -v $rotcontrolz1) ,(floatSliderGrp -q -v $rotcontrolz2))); move (rand ((floatSliderGrp -q -v $movcontrolx1) ,(floatSliderGrp -q -v $movcontrolx2))) (rand ((floatSliderGrp -q -v $movcontroly1) ,(floatSliderGrp -q -v $movcontroly2))) (rand ((floatSliderGrp -q -v $movcontrolz1) ,(floatSliderGrp -q -v $movcontrolz2))); scale (rand ((floatSliderGrp -q -v $sclcontrolx1) ,(floatSliderGrp -q -v $sclcontrolx2))) (rand ((floatSliderGrp -q -v $sclcontroly1) ,(floatSliderGrp -q -v $sclcontroly2))) (rand ((floatSliderGrp -q -v $sclcontrolz1) ,(floatSliderGrp -q -v $sclcontrolz2))); $loop = $loop + 1; } }
So, once I have that mel made, do I just create a button on my GUI which calls randomduplicate? And, will the GUI set the variables from my slider bars into the above mel?