Mel - Maya Embedded Language

<HOME>   <PREVIOUS>   <NEXT>

Commands

MEL scripts are essentailly a list of commands that Maya executes. Each command has a list of arguments / flags associated with it. These arguments can be assigned when you write your command. If you do not assign them, Maya will use it's default settings for the command you are running. You can query or edit these arguments at a later time.

Help with Commands

Often times you may know the command you are coding but you may not know all of the flags associated with that command. There are a few places you can look to get help on commands. You can look online in Maya's Online reference: Help / Mel Command Reference or you simply use your script editor or Command shell by using the help command combined with the command you need help with.

help nurbsPlane;
// Result:

Synopsis: NurbsPlane [flags]
Flags:
-l -length Length
-n -name String
-p -position Length Length Length
-r -rotation Angle Angle Angle
-s -size Length
-w -width Length

//

What you will notice here is that Maya list the short flag name, the long flag name, and the value type associated with each flag.

Exercise: Use the HELP to look up sphere, polyShere, nurbsCube, and polyCube.

Using Attributes

To create a shape using the attributes you type the name of the command then the flag then a value

nurbsPlane -name myPlane -width 3.333;
or
nurbsPlane -n myPlane -w 3.333;
Exercise: Make a polySphere, name it, and set its radius.

Querying Commands

Another useful ability in Maya is the ability to query information from commands. To do this you need:

command -query attribute and name of the object you want the information from.

You can only query one attribute at a time.

First, make a polyCube:

polyCube -name Cubert -height 3.333;
Then query it:
polyCube -query -height Cubert;
// Result: 3.333 //
Exercise: Query your polySphere to find out the number of subdivisions in the X

Edit Commands

Along with the ability to query, you can also edit information.
polyCube -name Cubert -height 3.333;
polyCube -query -height Cubert;
// Result: 3.333 //
polyCube -edit -height 3.123 Cubert;
polyCube -query -height Cubert;
// Result: 3.123 //
An important aspect of the edit command to remember is that you can edit more than one flag at a time.
polyCube -edit -height 3.123 -width 1.345 Cubert;
Exercise: Edit your polySphere to change the radius. Query it to see the new change.

*Don't forget to save your MEL scripts to your Shelf if you would like to view or use them again.

Coding Conventions

  • MEL is case sensitive. Pay close attention to whether it is a capital or lowercase letter you should be typing.
  • Don't forget the ; at the end of each line.
  • The names of commands, variables, etc. always start with a lowercase then the second part starts with a capital letter. Ex: polyTorus
  • If a command or variable only is a single word, it should be lowercase.
  • <Top>