MEL - Maya UI Building


#221

Thanks for the prompt reply!
I thought you could just replace the command with the a string variable and it would be read like so when executed.

what is e.a short for?

thanks!


#222

I have another question I’d like to share with all of you.

 I'm trying to design a layout, but I'm unsure of wich layout types I need combined to pull this off(it's been edited in photoshop), if it's even possible. But, really there is no real use for this other than the fact that it just looks sweet and clean =). I just want to master UI creation as best as I can.


#223

ea. means each.

For what you did in photoshop, it is best to us a columnLayout. Your design is a pretty simple straight down design.


#224

Ah, thanks alot for clarifying.
Can you attach a button in a columnLayout to the far down edge?
I thought you needed a formLayout to do that.
Then I’ve been struggeling with the -adjustment flag to find a way to make the checkboxes and radiobuttons stretch to fit the window, but haven’t found a value that would allow it. About the textFieldButtonGrp command. Which flag is used to place it to fit the window from top to bottom with all the textfields laid out evenly.


#225

I’m sorry for cluttering up this fine thread, but I’m stuck. After several and several tries and playing around with different layouts I still can’t get it to act as i’d like.
Tried the formlayout and this works more like i intended as you can attach layouts to each other, but I don’t understand how you’re able to make button 1, 2 and 3 space out evenly between “Hi” and “Goodbye”

if (`window -ex layoutWin`)
deleteUI layoutWin;
window -widthHeight 300 205 layoutWin;
	string $form = `formLayout -numberOfDivisions 100`;
	
	string $top = `columnLayout -adj true`;
button -h 40 -l Hi  ;

setParent..;
	string $mid = `columnLayout -adj 1`;
button -l 1;
button -l 2;
button -l 3;

setParent..;
	string $bottom = `columnLayout -adj true`;
button -h 40 -l "Good Bye" -al center ;

setParent..;


	formLayout -edit

	-attachForm			$top	 "top"	5
	-attachForm			$top	 "left"   5
	-attachForm			$top	 "right"  5
	-attachNone			$top	 "bottom" 


	-attachControl		 $mid	 "top"	5 $top
	-attachForm			$mid	 "left"   5
	-attachForm			$mid	 "right"  5
	-attachControl		 $mid	 "bottom" 5 $bottom


	-attachNone			$bottom	 "top"
	-attachForm			$bottom	 "left"   5
	-attachForm			$bottom	 "right"  5
	-attachForm			$bottom	 "bottom" 5




		$form;

showWindow layoutWin;

Anyone, could really, really use some help. Thanks.


#226

Hey Geuse the first thing you can add is the -rs (rowSpacing) flag to the $mid columnLayout to help space out your buttons 1 ,2, and 3. I added the windowPref at the top under the delete ui check it just helps me to keep my windows consistent in there size. other than that I just played with the window height value and the attach for the $bottom button to get it spaced out to look even. Here is the code I tweaked. Hope this helps out.


      if (`window -ex layoutWin`)
    deleteUI layoutWin;
    if( `windowPref -exists layoutWin` )
    windowPref -r layoutWin;
    window -w 300 -h 225 layoutWin;
   	 string $form = `formLayout -numberOfDivisions 100`;
   	 
   	 string $top = `columnLayout -adj true`;
    button -h 40 -l Hi  ;
    
    setParent..;
   	 string $mid = `columnLayout -rs 5 -adj 1`;
    
    button -l 1;
    
    button -l 2;
    
    button -l 3;
    
    
    setParent..;
   	 string $bottom = `columnLayout  -adj true`;
    button -h 40 -l "Good Bye" -al center ;
    
    setParent..;
    
    
   	 formLayout -edit
    
   	 -attachForm			$top	 "top"	5
   	 -attachForm			$top	 "left"   5
   	 -attachForm			$top	 "right"  5
   	 -attachNone			$top	 "bottom" 
    
    
   	 -attachControl				$mid	"top"	5 $top
   	 -attachForm			$mid	 "left"   5
   	 -attachForm			$mid	 "right"  5
   	 -attachControl				$mid	 "bottom" 5 $bottom
    
    
   	 -attachControl			$bottom	 "top"	  97 $top
   	 -attachForm			$bottom	 "left"   5
   	 -attachForm			$bottom	 "right"  5
   	 -attachControl			$bottom	 "bottom" 0 $bottom
    
    
    
    
   		 $form;
    
    showWindow layoutWin;

#227

Thanks alot. However the “goodbye” button disappears when expanding the window.
I don’t have time right now to check the code, need to eat before going to see Wolverine in 50 mins. Also I was interested in spacing them out dynamically as you drag according to the height of the window.

Thanks for the effort, I appreciate it.


#228

Hi all,

Is there any possibility of having text mask or password mask on textField using mel… or any alternative way to do that in Maya… may be using python also no problem


#229

Hello

You could use a scrollField.
Get the last entered letter from it via keyPressedCommand. Save it somehow else and replace the text with * on each keystroke… Unfortunately there is no possibility using Mayas UI stuff this way. Not even with python because it would use the same controls.

but scrollField is somehow bitchy: If you ask the scrollfield for its text on keypressed command it sometimes returns the content from before the key was pressed. You could circumvent this with evalDeffered (evalDeffered(“scrollField -q -text myScrollfield”))…

But if you include QT with a python plugin you surely have such possibilities!


#230

hi all,

I m trying to learn MEL but its hard… because i dont have any one to ask when i got problems and the book i have isnt helpfull either.

but i got this code and now i want that :
string $liftCraneAngle = floatFieldGrp -l "Crane angle" -attribute Aframe_rotate.rotateY;

part to work. i probably wrote it all wrong but dont know how to do it.

i want to fill in my rotateY and then it has to rotate, i tryed allot but with 0 result.

with my slider group the code like this worked but i dont want a slider.
can any one help me out?

[size=2]if ( window -exists MyWindow )
{ deleteUI MyWindow; }
window -t “controls” MyWindow;

string $Mhook = “MainhookCluster”;
string $Auxy1 = “Aux1Cluster”;
string $WhipBlock = “WhipCluster”;
string $Auxy2 = “Aux2Cluster”;

columnLayout -adj true;
optionMenu -label “Hooks” -changeCommand “-select #1”;

menuItem -label “Main”;
menuItem -label “Aux_1”;
menuItem -label “Aux_2”;
[font=Verdana]menuItem -label “whip_block”; [/font]

setParent …;

rowLayout -nc 2 -adj true;
text -l Lift; text -l Setdown;
setParent …;

rowLayout -nc 5 -adj true;
string $liftCraneAngle = floatFieldGrp -l "Crane angle" -attribute Aframe_rotate.rotateY;

$setCraneAngle = floatFieldGrp -l "Crane angle";
setParent …;

rowLayout -nc 5 -adj true;
floatFieldGrp -label “Boom angle” -value1 0.0;
floatFieldGrp -label “Boom angle” -value1 0.0;

setParent …;

button -l OK;
button -l cancel;

showWindow;

[/size]


#231

How do I edit the inputs of a node through scripting???..For example, i tried editing the curvature of Bend node(non linear transformation), but doesnt work…Can anybody help Me???


#232

Hi there, I´m pretty new to UI scripting. I want tree buttons in a row that resize equally like the “blabla”-Apply-Cancel buttons in the standard tools. What layout should I take then? As I understood the rowlayout only resizes one element…so I probably would need a formlayout?

thanks a lot


#233

thats right. you’d have to utilize the -ap or attachPosition flag for this:

window;
formLayout myForm;
	button myButton1;
	button myButton2;
	button myButton3;
formLayout -edit
	-af myButton1 left 0
	-ap myButton1 right 0 33
	-ap myButton2 left 0 33
	-ap myButton2 right 0 67
	-ap myButton3 left 0 67
	-af myButton3 right 0
	-af myButton1 bottom 0
	-af myButton2 bottom 0
	-af myButton3 bottom 0
	myForm;
showWindow;

#234

I also have another question. I need checkboxes which are only active when activating another checkbox. I got it to work with a few if-elses now, but I now tried to pack all these dependend checkboxes in a frame layout to deactivate/activate my whole frame. Problem is, that this frame isn´t grey when deaktivated, like my checkboxes are (when nonactive).
Are there differences in the active/inactive feature between whole layouts and controls?

cheers


#235

[font=Arial]Hi all,[/font]
[font=Arial]im strugling with rather somthing simple I think.[/font]
[font=Arial]Im trying to setup a proc so i can change a value in my own UI and then it updates the object.[/font]
[font=Arial]but i get stuck all the time, could some one point me in the good derction?[/font]
[font=Arial]//----- sliders is where it starts[/font]

[font=Arial]( I want to change the [font=Courier New]Aframe_rotate.rotateY )[/font][/font]


showWindow;
 
if ( `window -exists MyWindow` ) 
 
{ deleteUI MyWindow; } 
 
window -t "controls" MyWindow; 
 
 
 
string $form = `formLayout -numberOfDivisions 1000`;
 
 
 
string $Mhook = "MainhookCluster"; 
 
string $Auxy1 = "Aux1Cluster"; 
 
string $WhipBlock = "WhipCluster"; 
 
string $Auxy2 = "Aux2Cluster"; 
 
 
 
//--- MENU---
 
string $menutje = `optionMenu -label "Hooks" -changeCommand "-select #1"`;			 
 
			menuItem -label "Mhook";			 
 
			menuItem -label "Aux_1";			 
 
			menuItem -label "Aux_2"; 			 
 
			menuItem -label "whip_block"; 
 
 
 
//--- SLIDERS---
 
global proc setvalue(){
 
			float $entervalue = ` value Aframe_rotate.rotateY`;
 
}
 
string $liftCraneAngle = `floatFieldGrp -l Crane_Angle -cc "setvalue"`; 
 
string $liftBoomAngle = `attrFieldSliderGrp -min -5 -max 78.68 -attribute Boom_controler.BOOM -l "Boom angle"`; 
 
 
 
//----- BUTTONS------
 
 
 
string $keyer = `button -l "Set point" -c setKeyframe`;
 
string $player = `button -l "PLAYBLAST" -c playblast`;
 
string $cancel = `button -l cancel`;
 
string $undoer = `button -l "Undo" -c "undo"`;
 
 
 
string $vieuwScreen = `modelEditor -displayAppearance smoothShaded -dtx on -gr off -alo off -pm on`;
 
 
 
//---- FORMLAYOUT---
 
 
 
formLayout -edit
 
 
 
-attachForm $menutje "top" 5
 
 
 
-attachForm $liftCraneAngle "top" 70
 
-attachForm $liftCraneAngle "left" 70
 
 
 
-attachForm $liftBoomAngle "top" 100
 
-attachForm $liftBoomAngle "left" -70
 
 
 
-attachForm $keyer "top" 150
 
-attachForm $keyer "left" 140
 
 
 
-attachForm $undoer "top" 150
 
-attachForm $undoer "left" 180
 
 
 
-attachForm $player "top" 150
 
-attachForm $player "left" 450
 
 
 
-attachForm $cancel "top" 150
 
-attachForm $cancel "left" 530
 
 
 
-attachForm $vieuwScreen "top" 250
 
 
 
$form;
 
 
 
showWindow;
 
 
 


#236

I want 6 radioButtons in a 2 columnlayout like the image, but seems LabelArray can only hold a maximum of 4 values. =/


#237

have a look at the radioCollection-docs. you can have as many radioButtons in the collection as you like! And you can exchange the columnLayout with any layout you like. As formLayout for instance!

btw: from the images I’m not getting where you’re approaching to ;]


#238

Ah thanks, will look into that.
It’s actually supposed to be an autorigger for a leg. So because you are free to use your preferred orientation of joints I need to know in what axis the control groups for the foot’s ik handle should rotate in for the roll attribute to work as expected. :wink:

I’m really into setting the orientation myself and testing simple smooth bind with fk rotations before setting it up.
So the script will work like this:

First select a joint in the chain and press the button. It will rename the whole chain and create, scale and place out controls for the leg. Both ik and fk. Then it will prompt you with an additional window.
Before you continue the setup you are free to scale and move the controls as you please. When you’re happy you press the button in the newly created window “continue setup”.

Your joint chainvand control curves will copy, mirror and rename themselves correctly. When all this is done the real setup procedure takes over and creates the rig for both L and R side based on the names which has been given the controls and joint chains prior. I want something easy but with a bit of custom alternatives. For instance if you need the jointchain orientation to point in the z direction and for instance have x as the twisting axis it will still work without having to modify the code. Also, especially controls, I often want to scale or perhaps change for other autoriggers and I’m not really allowed to do that in an easy way. So I end up scaling the cv:s after the rig has been created, but I want simplicity and control and this way I can have the left and right footCtrls exactly the same size without to much fuzz. Yippie =).

I’m sorry I went off topic just wanted to share my ideas and then I ran off.

Thanks again.


#239

I’m making a ui in PYTHON that will have sections generated and removed by the user. What are some ways to generate and remove rows in a UI?


#240

If you have rows the columnLayout is probably the most simple way to arrange your lines.

You can just deleteUI the desired elements from it and it rearranges. If you create new elements parented under the columnLayout they will be put last.

example:

// create a window with columnLayout and controls:
window;
columnLayout testColumnLayout;
checkBox -label 1 testcheckBox1;
checkBox -label 2 testcheckBox2;
checkBox -label 3 testcheckBox3;
showWindow;

// remove a control:
deleteUI testcheckBox2;

// create new control:
checkBox -label 4 -parent "testColumnLayout" testcheckBox4;