MEL - Maya UI Building


Thanks, but I still can’t figure it out. I did as you suggested but the buttons are still behind the image. It seems that no matter what order I put the buttons and the image, the image is always in front. Is there anything else I could be missing?

Edit: Curiously if I instead use a symbolButton for the background image but have “-enable 0” so it cannot be clicked the control buttons are placed in front and work fine. The problem with this is “-enable 0” makes the image black and white.


This might be a useful reference for people trying to understand how to hook up callbacks in Maya python:


hello. im Gabriela and i would like your help to have a job that could help me. work is autodesk maya mel proxy.
my work consists of the following

Create a script that allows me to create the proxy of a helicopter (model of a helicopter in
very low poly)
 must include a general controller type Nurbs Circle function as father of all
 must create an expression that allows me to assess:
 If the helicopter is on the ground not moving propellers.
 If the helicopter rises must turn the propellers.

appreciate a reply thanks. :sad:


We are not going to do your homework for you. Post code so we can see what you are struggling with.


Maya gui trivia: somebody knows how to hide the x button in a widget so users cannot close them? Or make hitting that button crash save?


I’m learning to use Python in Maya and I’ve got a simple question. I’m creating a UI window code where I’m setting the pivot = of a .nurbsCube(). I created this Float Field Group that has 3 value fields.

pivotSet = cmds.floatFieldGrp(numberOfFields= 3, label= 'Pivot', value1= 3 ,value2= 1,value3= 1)

I’m trying to set the values of this field in another function that will use that pivotSet for the pivot =:

pivotSet = cmds.floatFieldGrp(pivotSet, query= True, value1= True ,value2= True, value3= True)

However, when I do this the function only returns a single float (value1) instead of all three values, so how can I fix this?


To ‘set’ the value you need to ‘edit’ the floatFieldGrp, ‘Query’ returns the existing values.

 cmds.floatFieldGrp(pivotSet, edit= True, value1= 1,value2= 2, value3= 3)


 cmds.floatFieldGrp(pivotSet, edit= True, value= (1, 2, 3)

Hope that helps :slight_smile:


Awesome, that did it! Thanks!


You’re welcome


So I’m trying to set the vector direction of a uniform field by a value queried from a FieldGrp. However, when I try using the method below I get the following error:

# Set FieldGrp  
frontUniDir = cmds.floatFieldGrp(numberOfFields = 3, label = 'Front Wind Dir', value = ( -1.0, 0, 0, 0 ) )

# Query FieldGrp vector values
frtUniDirVal = cmds.floatFieldGrp( frontUniDir , query = True, value = True )

# Set Uniform Field Direction
cmds.setAttr( 'snowUniformField_Front.direction', frtUniDirVal )

Error: setAttr: Error reading data element number 1: [-1.0, 0.0, 0.0]

Traceback (most recent call last):

File “<maya console>”, line 38, in editCreate

File “<maya console>”, line 116, in editSnow

RuntimeError: setAttr: Error reading data element number 1: [-1.0, 0.0, 0.0]


Try adding this to the setAttr -row:


Try adding this to the setAttr -row:

Tried it and I got the same error. I also tried the code below, but once again the same error.

    cmds.setAttr( 'snowUniformField_Front.direction', frontUniDir[0], frontUniDir[1], frontUniDir[2], type = 'float3' )


guys, pardon for this absurd question, Im very newbie to MEL. I wanted to create a simple UI window with only 1 floating number input to modify stepsnap value.

I have followed some simple tutorial to create window with floating input =

// the name of the float field
global string $floatFieldName="";

        global proc floatValueChanged() {
            global string $floatFieldName;
            // query the value from the float field
            $value = `floatField -query -value $floatFieldName`;
            // print value
            print("newValue="+ $value +"


        // window creation scoped to prevent unesseccary
        // globals being defined
            string $window = `window`;
            showWindow $window;

now I dont know how to connect that with the Mel command =

manipMoveContext -e -snapValue 10 Move;

Im very newbie so pardon for this simple question. Id appreciate any help.
Thank you


Hi, you could borrow some of my code for this if you want;

 global proc stepSize_move(){
 	int $mayaver = `about -v`;
 	string $window = "stepSizeWindow";
 	int $moveStepQ = `manipMoveContext -q -sv Move`;
 	if (`window -ex $window `)
 		{ deleteUI $window;}
 	window -title "Adjust Step Size" -width 200 -height 100 -rtf 1 $window;
 	manipMoveContext -e -snap true Move;
 	manipMoveContext -e -snapRelative true Move;
 	columnLayout -adjustableColumn true;
 	if ($mayaver <= 2015)
 		floatFieldGrp -nf 1 -pre 2
 			-label ("Move (mm) "+(uiRes("m_manipMoveProperties.kStepSize")))  
 			-v1 ($moveStepQ * 1)
 			-cc ("manipMoveContext -e -snapValue (#1/10) Move;")
 	if ($mayaver >= 2016)
 		floatFieldGrp -nf 1 -pre 2
 			-label "Move (mm)"
 			-v1 ($moveStepQ * 1)
 			-cc ("manipMoveContext -e -snapValue (#1/10) Move;")
 	button -label "Close" -command ("deleteUI -window " + $window +"; manipMoveContext -e -snapValue 1 Move;");
 	setParent ..;
 	showWindow $window;

I never bothered making it more efficient as it is a hack job, but it works really well.


Hi, Hamburger, thanks for the quick reply.
I tried to use ur code but nothing happened?

I am using Maya 2016 btw


Well what I posted is a script.

However it is a procedure which is slightly different to what you were doing. With a script what you were typing, Maya can run it every time but that’s not the most effecient way to run code so instead we can tell Maya what the script is through what’s called a procedure. Basically a little shortcut so Maya knows which script to use instead of typing it all out.

We can just run it everytime with this command;


and Maya will recall the entire script itself. If you want to do it the other way you can just remove this line; global proc stepSize_move(){

and the very last line; }

So save that “procedure” as a mel file (stepSize_move.mel) and put in in your My Documents\maya\2016\scripts. Start Maya and just type in (or save) stepSize_move and Maya will know which mel file to use. That’s the basics, hope it helps.


Thank you sirrr, you helped me alottttttt :bounce: :bounce: :bounce: :bounce: :bounce: :bounce: :bounce: :bounce: :bounce:

it works perfectly now :slight_smile:


I was searching for a visual way to build the Mel gui. As i’m not a coding guy it’s really hard to build the ideal Gui i want.

I googled a lot about it but unfortunately found nothing. Although whatever i’ve found is way too old and not that much useful.

So if there’s anyone know any tool like this please help me.please urgently. :slight_smile:


formlayout have attachform/attachposition/attachcontrol properties.
attachform : attaches inner controls relevant to formlayout its ok.
attachposition: attach an inner control to another innercontrol.

but what is attachcontrol is ? isnt it acts same as attachform ?


Hi ,
i need some help . i want to link my few optionMenu with a textFieldGrp textfield .