Just like MEL, you can
enter Python commands in the Command Line or
the Script Editor. The Command
Line can only accept single line Python commands, while
the Script Editor provides a method
to input multiple Python commands and view the results.
Editor displays a running history of executed commands
and the results of commands that Maya executes. You can copy most
commands from the history section of the Script Editor and
paste them in the input section to execute them. However, the results
of Python commands are not echoed to the Script Editor exactly
For more information,
To set up the Script Editor.
To type a Python command in the Script
> General Editors > Script Editor.
- Select a Python tab
in the Script Editor.
- Type the following command in the input
section of the Script Editor and execute it
by pressing on the
numeric part of your keyboard, or pressing + .
You now have access to
Maya commands through the maya.cmds module.
NoteThis is how you load
modules in Python. For more information about other Python modules,
see the online Python documentation.
By convention throughout
the documentation and the Python command reference, the maya.cmds module is renamed cmds, but you can rename the module
anything you like.
In the Script
Editor, the Enter (Windows) or Return (Mac OS X) key
above the Shift key does not execute a command. It starts a new
line so you can type several commands before executing them.
You can import maya.cmds
automatically at startup
by creating a file called userSetup.py
your Maya scripts directory. The userSetup.py
contain any Python commands you want to execute at startup.
For more information,
Initializing the Maya Environment in and for Python.
- Create a polygonal cube by typing the
A polygonal cube is created
at the origin. This is equivalent to using the polyCube command in MEL.
The command is removed
from the input section of the Script Editor after execution.
The command and the result of the command is output to the upper
section of the Script Editor. The results
of Python commands are displayed in the Script Editor between a
set of Python commenting characters (#).
You can also enter commands
in the Command Line.
Show the Command
Line by selecting
Display > UI Elements.
By default the Command Line is in MEL script
entry mode. You can change the mode by clicking on the text in the
lower left hand corner. To enter Python commands, the command line
must be in Python mode.
To use a Maya command with positional
- Move the polygonal cube that you created
with the following Python command:
The polygonal cube moves
to the XYZ co-ordinates 1,2,3.
The move command accepts
XYZ co-ordinates as its commands arguments.
- Scale the polygonal cube with the following
- Re-scale the polygonal cube with the
When a command is not
provided with enough command arguments, the command uses the default
arguments. The polygonal cube X scale is set to three, but the Y
and Z scale values are set to their default argument one.
- Delete the selected polygonal cube.