4.2 mel -- Wrappers around the MEL commands

This module contains all MEL commands wrapped inside regular Python functions. For example, calling mel.ls() is equivalent to calling the MEL command ls and will return a list of object names. Please consult your Maya documentation for a reference of all MEL commands.

Function names:

The name of a Python function in the mel module is identical to the name of the corresponding MEL command.

The only exceptions are commands that are named after a reserved Python keyword (such as exec) which will be prepended with the prefix maya_.

Passing arguments:

Arguments must be passed as keyword arguments. The argument name is identical to the flag name in MEL (either the short or long names can be used). The value is the argument of the flag. The value None has to be passed if the flag does not take any arguments.


mel.sphere(radius=2.5, name="Ball", pivot=(0,0,2.5))

The above line is equivalent to the MEL command sphere -radius 2.5 -name "Ball" -pivot 0 0 2.5.

print mel.sphere(query=None, radius=None, name="Ball")

This line is equivalent to printing the result of sphere -query -radius -name "Ball".

mel.curve(degree=1, point=[(0,0,0), (1,1,1)])

This call contains a multi-use flag (i.e. a flag that can appear several times) and is equivalent to the MEL command curve -degree 1 -point 0 0 0 -point 1 1 1.

The values of an argument are transformed to a string according to the following rules:

If you want a multi-use flag to appear more than once you have to pass the individual values as a list or a tuple (see the third example from above).

Return values:

The return value of the MEL command is converted into the corresponding Python type.