Script Editor menus and hotkeys

File

Load script

Loads the contents of a text file into the Script Editor.

Source script

Executes the contents of a text file.

Locally scoped procedure definitions must appear before they are called. (MEL doesn't let you forward reference locally scoped procedures.) For example, in a file called noForwardRef.mel, define the local procedures before they are referenced as follows:

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 history pane.

Clear Input

Clears the input pane.

Clear All

Clears both the history and input panes.

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:.

Note:

Suppressing Script editor messages does not suppress messages from appearing in the Help Line.

Suppress Duplicate Variable Messages

Disable this option so that a warning is generated when a MEL variable is declared within the same scope as another variable with the same name. In general, the warning indicates an error in the script. The default state for this option is on.

Warnings are generated when a script is sourced, not when it is executed.

A scope in MEL encompasses all the code between a pair of { } that is not further nested within another pair of { }.

See the following for examples of scope:

proc testo(int $arg1)
{
    <scope A>

    if ($arg1 > 3)
    {
        <scope B>
    }

    else
    {
        <scope C>
    }

    <scope A>
}

A procedure's parameters are considered to be variables declared within the procedure's top scope. In the example above, $arg1 is considered to be a variable declared within scope A. Therefore, if you subsequently declare a variable as $arg1 anywhere in scope A, a warning occurs.

Code outside of all procedures is considered global scope and should not generate any warnings.

In addition to this menu item, you can also use the melOptions command's duplicateVariableWarnings flag to control the generation of warnings. When this flag is enabled, warnings are generated.

The setting of the menu item and the setting of the command flag have an inverse relationship. Changing the state of one also updates the state of the other. When you enable the menu item, the command flag is disabled, and if you enable the command flag, the menu item is disabled.

Upon start up of Maya, the melOptions -duplicateVariableWarnings flag is set according to the value saved in the optionVar melDuplicateVariableWarnings. If this optionVar does not exist, the flag is set to 0. The optionVar is updated every time the Suppress Duplicate Variable Messages checkbox is enabled or disabled; or, whenever preferences are saved. In other words, if you change the state of the flag using melOptions -duplicateVariableWarnings, the optionVar is only updated when preferences are saved. This implies that the optionVar generally reflects the state of the flag, unless it is changed via the melOptions command, in which case the optionVar must wait until the next time preferences are saved to be updated.

You can query the value of the duplicateVariableWarnings flag by running melOptions -q -duplicateVariableWarnings in the command line. Querying does not change the value of the flag.

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.

Show line numbers

Shows line numbers in the Script Editor.

Use tabs for indent

Select this option so that when you click Tab to indent, a tab will be created rather than individual spaces.

Auto-close braces

Automatically closes blocks with a curly brace.

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 Ctrl + Spacebar 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 Ctrl + Spacebar 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.

Tabs

Note:

Previously, these options were available from the Command menu.

New Tab

Creates a new tab. The source type window opens and lets you choose either MEL or Python as the executer source language. You must choose whether the tab is for MEL or Python. Alternatively, you can click on the bottom pane or use the Ctrl+T hotkey.

Rename Tab

Renames the current tab.

Go to Previous Tab
Select this option or use the Ctrl+Shift+Tab hotkey to navigate to the previous tab.
Go to Next Tab
Select this option or use the Ctrl+Tab hotkey to navigate to the next tab.
Delete Tab

Select this option or use the Ctrl+W hotkey to delete the current tab.

Delete All Other Tabs

Deletes all tabs except for the current tab.

Note:
You can also create, rename or delete tabs by right-clicking a tab and selecting the option you want. Delete Tab deletes the tab that you are right-clicking from, and Delete All Other Tabs delete all tabs except the one that you are right-clicking from.

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.