MEL - Maya UI Building


#201

It looks like you are missing the “-” in front of the minValue/maxValue flags, and the `; at the end of that floatSliderGrp call.

After that you might have some typos in the longer formLayout call…eg. I think the attachPosition flag takes 2 integers at the end.


#202

thnx but thats not it… it has to something with the select line:

string $Ftrustsel = button -l "SELECT";

[size=1]// Error: string $Ftrustsel = button -l "SELECT"; //

// Error: Line 6.6: Syntax error //

[/size]


#203

Are you sure? Have you copy/pasted exactly what you are running? Because without the “`;” at the end of the minValue line, it will continue on till the end of that button line and would spit out just that kind of error.


#204

ow stupid me i forget to put the ; at the end… now it goes further but then i get the next fault

string $example_window = window;

string $example_form = formLayout -numberOfDivisions 100;

string $Ftrust_grp = `floatSliderGrp -l “draai”

-field false

-minValue 0.0 -maxValue 10.0`;

string $Ftrustsel = button -l "SELECT";

string $Ftrustkey = button -l "KEY";

formLayout -edit

-attachPosition $Ftrust_grp “top” 10

-attachForm $Ftrust_grp “left” 10

-attachNone $Ftrust_grp “bottom”

-attachForm $Ftrust_grp “right” 10

-attachPosition $Ftrustsel “top” 20

-attachForm $Ftrustsel “left” 10

-attachNone $Ftrustsel “bottom”

-attachForm $Ftrustsel “right” 10

-attachPosition $Ftrustkey “top” 30

-attachForm $Ftrustkey “left” 10

-attachNone $Ftrustkey “bottom”

-attachForm $Ftrustkey “right” 10

$example_form;

showWindow $example_window;

// Error: line 25: Error while parsing arguments. //

but thnx so far it helped :smiley: but you also know why i get this last message?
(line 25 is the last one)


#205

I think the “-attachPosition” flags take “string string int int” as arguments, but you only have 1 int in your call.


#206

aah thnx again …
i changed a lot since last post … but now my window wont show…
but the wierd thing is:
window -title “Form Stuff”;

string $type = formLayout -numberOfDivisions 100;

*** bla bla bla stuff***

[size=1]$type;

showWindow;

****** in 1 script this works and in the other script i get an error.
[size=1]// Error: line 53: Error while parsing arguments. //

[/size][/size]


#207

The “error while parsing arg’s” part you will get if you have something wrong with the formLayout call. I would try a shorter version of the formLayout call until you find the lines that are causing the problem.


#208

your -attachPosition lines should look like this:


-attachPosition $Ftrust_grp "top" 10 10


#209

oki guys thnx for the help :smiley:

my UI is almost done now .


string $test_window = `window`;
string $form = `formLayout -numberOfDivisions 100`;
//-----------------------------
string $trustLv = `attrFieldSliderGrp -min -20 -max 20 -attribute trustvoor4.rotateZ -l "truster LV"`;
string $trustLvSel = `button -l "SELECT" -command select trustvoor4`;
string $trustLvKey = `button -l "POI"`;
//----------------------------
string $trustRv = `attrFieldSliderGrp -min -20 -max 20 -attribute trustvoor2.rotateZ -l "truster RV"`;
string $trustRvSel = `button -l "SELECT" -command select trustvoor2`;
string $trustRvKey = `button -l "POI"`;
//----------------------------
string $trustLvB = `attrFieldSliderGrp -min -20 -max 20 -attribute trustvoor3.rotateZ -l "truster LV2"`;
string $trustLvBSel = `button -l "SELECT" -command select trustvoor3`;
string $trustLvBKey = `button -l "POI"`;
//----------------------------
string $trustRvB = `attrFieldSliderGrp -min -20 -max 20 -attribute trustvoor1.rotateZ -l "truster RV2"`;
string $trustRvBSel = `button -l "SELECT" -command select trustvoor1`;
string $trustRvBKey = `button -l "POI"`;
//----------------------------
string $luikopn = `attrFieldSliderGrp -min -5 -max 0 -attribute Luikopener.translateX -l "Open luik"`;
string $openSel = `button -l "SELECT" -command select Luikopener`;
string $trdown = `attrFieldSliderGrp -min -6 -max 0 -attribute TrustersVOOR.translateY -l "Trusters Down"`;
string $trdownSel = `button -l "SELECT" -command select TrustersVOOR`;
//----------------------------
string $turnLmid = `attrFieldSliderGrp -min -180 -max 180 -attribute Ltrust.rotateY -l "ROT L"`;
string $turnLmidSel = `button -l "SELECT" -command select Ltrust`;
string $turnRmid = `attrFieldSliderGrp -min -180 -max 180 -attribute Rtrust.rotateY -l "ROT R"`;
string $turnRmidSel = `button -l "SELECT" -command select Rtrust`;
//----------------------------------
string $schroefLmid = `attrFieldSliderGrp -min -20 -max 20 -attribute SchroefL.rotateX -l "ROT Schroef"`;
string $schroefLmidSel = `button -l "SELECT" -command select SchroefL`;
string $schroefRmid = `attrFieldSliderGrp -min -20 -max 20 -attribute SchroefR.rotateX -l "ROT Schroef"`;
string $schroefRmidSel = `button -l "SELECT" -command select SchroefR`;
//-----------------------------------
string $trustLacht = `attrFieldSliderGrp -min -180 -max 180 -attribute trusterLachter.rotateY -l "Schroef L achter"`;
string $trustLachtSel = `button -l "SELECT" -command select TrusterLachter`;
string $TrustRacht = `attrFieldSliderGrp -min -180 -max 180 -attribute TrusterRachter.rotateY -l "Schroef R achter"`;
string $trustRachtSel = `button -l "SELECT" -command select TrusterRachter`;
//-----------------------------------
string $schroefLacht = `attrFieldSliderGrp -min -20 -max 20 -attribute sturenL.rotateX -l "ROT Schroef"`;
string $schroefLachtSel = `button -l "SELECT" -command select schroefLacht`;
string $schroefRacht = `attrFieldSliderGrp -min -20 -max 20 -attribute sturenR.rotateX -l "ROT Schroef"`;
string $schroefRachtSel = `button -l "SELECT" -command select schroefRecht` ;
//------------------------------------
string $unselect = `button -l "Unselect" -c "select -cl"`;
string $player = `button -l "Play" -c "play -forward true"`;
string $stopper= `button -l "Stop" -c "play -state off"`;
string $rewinder = `button -l "Rewind" -c "currentTime 0"`;
string $undoer = `button -l "Undo" -c "undo"`; 
//---------------------------------------
string $keyert = `button -l "KEY" -c "setKeyframe"`;
 
formLayout -edit
-attachForm $trustLv "top" 5
-attachForm $trustLv "left" 0
-attachForm $trustLvSel "top" 5 
-attachControl $trustLvSel "left" 5 $trustLv 
-attachForm $trustLvKey "top" 5
-attachControl $trustLvKey "left" 5 $trustLvSel
-attachForm $trustRv "top" 5
-attachControl $trustRv "left" 5 $trustLvKey
-attachForm $trustRvSel "top" 5 
-attachControl $trustRvSel "left" 5 $trustRv 
-attachForm $trustRvKey "top" 5
-attachControl $trustRvKey "left" 5 $trustRvSel
//--------------------------------------------
-attachForm $trustLvB "top" 30
-attachForm $trustLvB "left" 0
-attachForm $trustLvBSel "top" 30 
-attachControl $trustLvBSel "left" 5 $trustLvB
-attachForm $trustLvBKey "top" 30
-attachControl $trustLvBKey "left" 5 $trustLvBSel
-attachForm $trustRvB "top" 30
-attachControl $trustRvB "left" 5 $trustLvBKey
-attachForm $trustRv2Sel "top" 30 
-attachControl $trustRvBSel "left" 5 $trustRvB
-attachForm $trustRvBKey "top" 30
-attachControl $trustRvBKey "left" 5 $trustRvBSel
//------------------ NEXT group-----------
-attachForm $luikopn "top" 75
-attachForm $luikopn "left" 0 
-attachForm $openSel "top" 75
-attachControl $openSel "left" 5 $luikopn
-attachForm $trdown "top" 75
-attachControl $trdown "left" 40 $openSel
-attachForm $trdownSel "top" 75
-attachControl $trdownSel "left" 5 $trdown
//--------------------------------------------
-attachForm $turnLmid "top" 100
-attachForm $turnLmid "left" 0 
-attachForm $turnLmidSel "top" 100
-attachControl $turnLmidSel "left" 5 $turnLmid
-attachForm $turnRmid "top" 100
-attachControl $turnRmid "left" 40 $turnLmidSel
-attachForm $turnRmidSel "top" 100
-attachControl $turnRmidSel "left" 5 $turnRmid 
//------------------------------------------
-attachForm $schroefLmid "top" 125
-attachForm $schroefLmid "left" 0 
-attachForm $schroefLmidSel "top" 125
-attachControl $schroefLmidSel "left" 5 $turnLmid
-attachForm $schroefRmid "top" 125
-attachControl $schroefRmid "left" 40 $schroefLmidSel
-attachForm $schroefRmidSel "top" 125
-attachControl $schroefRmidSel "left" 5 $schroefRmid
//----------------------------------------
-attachForm $trustLacht "top" 170
-attachForm $trustLacht "left" 0 
-attachForm $trustLachtSel "top" 170
-attachControl $trustLachtSel "left" 5 $trustLacht
-attachForm $TrustRacht "top" 170
-attachControl $TrustRacht "left" 40 $trustLachtSel
-attachForm $trustRachtSel "top" 170
-attachControl $trustRachtSel "left" 5 $schroefRmid
//------------------------------------------
-attachForm $schroefLacht "top" 195
-attachForm $schroefLacht "left" 0 
-attachForm $schroefLachtSel "top" 195
-attachControl $schroefLachtSel "left" 5 $trustLacht
-attachForm $schroefRacht "top" 195
-attachControl $schroefRacht "left" 40 $trustLachtSel
-attachForm $schroefRachtSel "top" 195
-attachControl $schroefRachtSel "left" 5 $schroefRmid
//------------------------------------------
-attachForm $unselect "top" 225
-attachForm $unselect "left" 385
-attachForm $player "top" 225 
-attachControl $player "left" 10 $unselect
-attachForm $stopper "top" 225 
-attachControl $stopper "left" 10 $player
-attachForm $rewinder "top" 225 
-attachControl $rewinder "left" 10 $stopper
-attachForm $undoer "top" 225 
-attachControl $undoer "left" 10 $rewinder
//------------------------------------------
-attachForm $keyert "top" 250
-attachPosition $keyert "left" 2 50 
$form;
showWindow $test_window;
 

as some of you may have noticed the select buttons are all wrong.
when i make that button without making it a string it works nicely but when i make it a string they wont select. an example is :
string $turnRmidSel = button -l "SELECT" -command select Rtrust;

what is wrong with it?

an other question is this.
i want to make a KEY button on the bottem of the ui. ( its already there )
but i want it the size of the ui. and not the size of the word. how can i do this?


#210

I think what is happening here is that the -command flag automatically grabs “select” as your command because you didn’t explicitly quote the string that you wanted to run. Then it uses “Rtrust” as the name that you want to use for the button. If you had also provided a name at the end, then you’d probably get an error about too many parameters. It should work fine if you just add quotes around “select Rtrust”.

Do you mean that you want the key button to be as wide as the window? If so, then you should just be able to attach the left/right sides of the button to the form instead of a position which puts it at a percentage of the width.

eg. replace your -attachPosition $keyert line with:


 -attachForm $keyert "left" 2
 -attachForm $keyert "right" 2
 

#211

aaah your a great help!.. the select works now… only i get some other messages when i putted in “” but ill try to find out… and yes the key has to be as big as the window.i putted that text in the screen… but cant test it now because i get some wierd warnings al of a sudden… ill try to fix that, but the first try with select worked.
So thnx allot… ill update when im done… cause i have some other small problems ( well not realy problems but i wjust want to know how to do and i hope you can help me a bit with it :wink: )


#212

oki everything is ok now. only i still need to set some sliders.

Ths sliders that went from -20 to 20 i changed to -360 to +360 so its 1 total spin.

Example is :
string $trustLv = attrFieldSliderGrp -min -360 -max 360 -attribute eerstetruster.rotateZ -l "truster LV";

string $trustLvSel = button -l "SELECT" -command "select eerstetruster";

string $trustLvKey = button -l "POI";

now that POI button is the thing i want to make work.
When i select the “eerstetruster” and give a key at 1 with 0 degree and at frame 5 with 180 degree. it will make a animation curve for only rotateZ ( i locked the other atributes)
So that curve i want to make post infiniti ( the POI )

selectKey -add -k -t 0 -t 5 trustvoor3_rotateZ ;

is what i get when i select it, and

setInfinity -poi cycle;

is what i get if i make it post infiniti.
but since my first keys can variate from 0 and 5 i can’t totaly use that line.
i gues it must be something like: ( dont laugh :stuck_out_tongue: )

$trustLvKey = selectKey -at trustvoor3_rotateZ setInfinity -poi cycle;

my scripting sucks i know :wink: but atleast im trying
but as you could gues this wont work. can any one help me with this? or sugestions

( i actualy want to rotate the propellor with te slider and the furhter i go to the right the faster the propellor turns with infinity but no one seemed to know this cause no one responded to the other topic. so now i gonna try this)


#213

Hi everybody.
I’m working on a UI interface for a simple autorigger for a leg, but I’m already stuck. Found a nice thread where I got help setting the base up, but I can’t figure out how to copy it for the remaining inputs. I need at least 6 “textFieldsGrp” for specifying all of the legjoints:
Leg, knee1, knee2, ankle, ball, toe. I prefer two joints for the bending of the elbow and knee.

I visualize it working like this: You import or build a simple joint chain and name the joints to your preference. Then you execute the autorigger where you specify and load (or write) each joint in the appropriate field. At last you simply hit a button called “setupLeg” and it will do the rest for you.

But as said, I’m stuck and would really appreciate any advice on how to proceed.

if ( `window -exists SetupLegUI` )
 	deleteUI SetupLegUI;
 
 
 window -t "autorig v.1.0" -wh 100 100 SetupLegUI;
 
 
 rowLayout -adj 1;
 
 string $controllerNameTextField;
 string $controllerNameButtonCommand[] = `ls -sl`;
 string $replacement = $controllerNameButtonCommand[0];
 
 $controllerNameTextField = `textFieldButtonGrp -label "Specify Leg Joint" -text $replacement -buttonLabel "set"`;
 
 string $cmd = "string $sel[] = `ls -sl`;";
 $cmd += "if (size($sel))";
 $cmd += "   textFieldButtonGrp -e -text $sel[0] " + $controllerNameTextField +";";
 
 textFieldButtonGrp -adj 2 -edit -buttonCommand $cmd $controllerNameTextField; 
 
 setParent..;
 
 
 window -edit -wh 420 300 -topLeftCorner 200 1150
 
 SetupLegUI;
 showWindow;

#214

Hm…I managed to solve it by simply changing the layout type to “columnLayout” instead of “rowLayout”. Why is that? Anybody?


#215

Hi guys.
Quick Question…

Is it possible to make a window run a command, say “sphere” , when you click the “X” to kill it?
You can run on minimize and restore, but I haven’t seen any flag for exiting. Is it possible?


#216

yes it is: http://download.autodesk.com/us/maya/2008help/Commands/scriptJob.html#flaguiDeleted


#217

Yeah, I thought of that :wink: But I was thinking without introducing the scriptJob. Sorry, I should have made that clear in the last post…


#218

If you have a float field group that consists of more than one float field, how can you know which value has been changed if you pass it to another procedure? There is only one change command. I’ve tried finding information on querying which of the fields are in focus but haven’t been able to find anything.

Any ideas?

Thanks,
/Christian


#219

Hi I’m playing around with colors in the UI and So I’ve created a variable to hold a blue color so I don’t have to type this in every field manually and if I want to change it I could just change it in the variable declaration.
string $bgc = “-bgc 0.4 0.7 1”;

the problem is when adding this to a rowLayout like so

//ROWLAYOUT START
rowLayout $bgc
-numberOfColumns 3
-columnWidth3 120 120 120;

it does not work and I can tell I’m doing something very wrong, I just can’t figure out how to write it correctly.


#220

Hey Geuse,

The problem is that you are declaring a string variable. If you want to change the -bgc you are going to need a float variable for ea. rgb or a float array. I hope this helps out.