MEL - Maya UI Building


#361

You’re welcome
:slight_smile:


#362

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]


#363

Try adding this to the setAttr -row:
type=float3


#364

Try adding this to the setAttr -row:
type=float3

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' )


#365

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`;
            columnLayout;
                floatField;
                
            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


#366

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;")
 			manipMoveSnapValue;	
 	}
 	if ($mayaver >= 2016)
 	{
 		floatFieldGrp -nf 1 -pre 2
 			-label "Move (mm)"
 			-v1 ($moveStepQ * 1)
 			-cc ("manipMoveContext -e -snapValue (#1/10) Move;")
 			manipMoveSnapValue;	
 	}
 	
 	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.


#367

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

I am using Maya 2016 btw


#368

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;

stepSize_move

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.


#369

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

it works perfectly now :slight_smile:


#370

HI,
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:


#371

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 ?


#372

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

Regards,
Supriyo