Type a command in the command line at the bottom of the Maya main window.
If the command line is not visible, you can turn it on by choosing Display > UI Elements > Command Line.
Click the Script Editor button in the bottom right of the main Maya window, or select Window > General Editors > Script Editor to open the Script Editor.
The Script Editor lets you type in longer, multi-line scripts and see their output in the history pane.
Type your script in the bottom pane of the Script Editor window.
In the script editor, you can use auto-completion to help you find command names more quickly. For more information, see Get help on a MEL command.
To execute the script do any of the following:
The script and the result appear in the top pane.
The Script Editor history pane shows you the line numbers that the errors have occurred on. You can turn off this option by selecting History > Line numbers in error.
You can turn off the line numbers in the bottom pane by selecting Command > Show line numbers.
All MEL and Python commands are highlighted as you enter them into their respective tabs in the Script Editor.
You can run MEL scripts as separate files. They have the extension .mel by default.
You can execute external script files in two ways:
When you source a MEL script, MEL does not allow you to forward reference locally scoped procedures. Locally scoped procedure definitions must appear before they are called. For example, in a file called noForwardRef.mel, define the local procedures before they are referenced.
proc myLocalProc() { print "In myLocalProc()\n" ; } proc anotherLocalProc() { print "In anotherLocalProc()\n" ; myLocalProc; } global proc noForwardRef() { print "Calling anotherLocalProc()\n" ; anotherLocalProc; }
If you change a script after sourcing it, the change is not automatically picked up by Maya. You need to re-run the script with File > Source Script.
MEL scripts and mayaAscii files are different things. If you rename a .ma file to a .mel file and source it, you may get errors. Alternatively, if you rename a .mel script to be a .ma file and open it, you may get errors or even crash Maya. Maya does special things while reading files to improve performance and not all commands are compatible with this.