In main menu bar: Window > General Editors
> Script Editor
In scene view: Panels
> Panel > Script Editor
The Script editor lets
you type in single or multi-line scripts in either MEL or Python
and see their output in the history pane.
Panes
The top pane shows the history of commands
and their results.
Type MEL or Python commands
and scripts in either the MEL or Python tab in
the bottom pane.
To execute the script
in the bottom pane, do one of the following:
- Press the Enter key on the numeric keypad
- Select Command > Execute.
- Select the text you want to execute and
press +
TipOn Windows, you can
change the font size of the text in the top or bottom panes of the
Script editor.
- Select the top or bottom pane of the Script
editor (click in the window), then hold the key
and scroll with your middle-mouse wheel.
The text gets larger
or smaller as you scroll.
Toolbar
You can access most Script
editor commands directly from this toolbar.
|
Load script. |
|
Source script. |
|
Save script. |
|
Save script to Shelf. |
|
Clear history. |
|
Clear input. |
|
Clear all. |
|
Show history. |
|
Show input. |
|
Show both. |
|
Echo all commands. |
|
Show line numbers. |
|
Execute all. |
|
Execute: executes selected text. |
|
Search down: searches for the text specified. |
|
Search up: searches for the text specified. |
|
Go: enter the line number in the text box and click this
icon.
|
Menus
File
- Load script
-
Loads the contents of
a text file into the Script editor.
- Source script
-
Executes the contents
of a text file.
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.
- Save script
-
Saves the selected text
to a text file.
- Save script to shelf
-
Adds a button to the
current shelf which executes the selected text.
Edit
The edit menu includes
standard editing commands and their associated hotkeys: Undo, Redo, Cut, Copy, Paste,
and Select All, as well as the
following commands:
- Go to line
-
Goes to the specified
line number.
- Search and replace
-
Opens a search dialog
where you can search for a string and replace it with a different
string. You can choose the search direction and choose whether your
search is case-sensitive.
- Indent Selection / Unindent
selection
-
You can indent or clear
the indent of selected text.
- Clear History
-
Clears the top pane of
the Script editor.
- Clear Input
-
Clears the bottom pane
of the Script editor.
- Clear All
-
Clears both the top and
bottom panes of the Script editor.
History
- Batch render messages
-
Shows batch rendering
messages in the Script editor.
- Echo all commands
-
When this item is on,
all MEL commands executed by Maya appear in the top pane of the Script
editor.
For example, if you select
Create > Polygon Primitives > Sphere,
the corresponding MEL command (polySphere)
that Maya executes is printed in the top pane.
- Line numbers in errors
-
Shows line numbers in
errors.
- Show stack trace
-
Opens another window which lists errors
and their line numbers in external script files. This is very useful
for debugging scripts in external files.
- Suppress command results
-
When
turned on, the Script editor does not show the result of commands.
Result messages start with //
Result:.
- Suppress info messages
-
When turned on, the Script
editor does not show informational messages. Informational messages
are of many different types and do not have a set prefix (except
for //).
- Suppress warning messages
-
When
turned on, the Script editor does not show
warning messages. Warning messages start with //
Warning:.
- Suppress error messages
-
When turned on, the Script
editor does not show error messages. Error messages start
with // Error:.
NoteSuppressing Script
editor messages does not suppress messages from appearing
in the Help Line.
- Suppress stack window
-
When turned on, the Script
editor suppresses the stack window. If stack trace is enabled, results
are returned to the output window instead of a separate stack window.
The Script editor menu
items can also be controlled through the scriptEditorInfo command
(-sr/suppressResults, -si/suppressInfo, -sw/suppressWarnings, -se/suppressErrors, -ssw/suppressStackWindow).
Command
The following commands
allow you to create, delete, and rename new tabs in the input area
of the Script editor.
- New Tab
-
Creates a new tab. You
must choose whether the tab is for MEL or Python.
- Rename Tab
-
- Select Tab
-
You can step through
the tabs using the Previous and Next commands.
- Delete Tab
-
- Show line numbers
-
Shows line numbers in
the Script editor.
- Command Completion
-
Auto-completes command
names as you type them. If Show Tooltip Help is
on, command names appear automatically as you type. If Show
Tooltip Help is off, you must press + to make
them appear.
- Object Path Completion
-
Auto-completes object
path names as you type them. If Show Tooltip Help is
on, command names appear automatically as you type. If Show
Tooltip Help is off, you must press + to make
them appear.
- Show Tooltip Help
-
Displays auto completed
commands and object paths as you type them.
- Show Quick Help
-
Displays the Quick
Help panel. You can search for commands and the panel
displays all valid flags for that command.
- Execute
-
Runs the MEL script in
the bottom pane of the Script editor.
You can also press Enter on the numeric keypad.
Command highlighting
All MEL and Python commands
are highlighted as you enter them into their respective tabs in
the Script Editor.
Saved MEL Scripts
MEL
scripts are automatically saved when Maya exits and restored in
the Script editor when Maya is
restarted.
In the event that Maya
shuts down unexpectedly and is able to write a backup scene file,
the current contents of each tab are written to text files and saved
in the same directory as the scene file. These filenames match that
of the backup scene file with the suffix -ScriptEditor-.
Additional notes
When Python requests
input through stdin (for example, the Python raw_input command),
a dialog box appears where you can type your input.