For Maya to be able to use MEL scripts they must be installed within the scope of Maya’s MAYA_SCRIPT_PATH configuration. Your Maya profile folder – created when you first run Maya – will be included in this configuration, and will contain a “scripts” folder that you can use to store and execute your own scripts.
||C:\Documents and Settings\<your login name>\My Documents\maya\scripts\
||/usr/people/<your login name>/maya/scripts/
|Mac OS X
||/Users/<your user name>/Library/Preferences/Alias/maya/scripts/
If you download a script, copy it into this folder.
Maya’s Script Editor may be used to execute MEL commands – either by typing them in, or by pasting or loading the commands. However, you may find that executing a script in the Script Editor doesn’t appear to do anything. This is because the script is laid out so that it sets up custom commands for you to use in the form of procedures. These are designated by a special declaration within the script, such as:
global proc myCommand()
There should be one main procedure in a script that will launch its UI (if there is one), or do whatever it is that it’s supposed to do. This procedure is typically given the same name as the script. Thus, the above example would be the main procedure for the script “myCommand.mel”.
After installing the script as described above, execute this procedure by entering the following in the Script Editor:
As noted in my Introduction To MEL, if you enter a MEL command such as “myCommand” Maya will scan your ‘scripts’ folder(s) for a script file named “myCommand.mel”. In this way Maya can automatically use a function from a script without explicitly loading the script first. If the author of the script did not follow this convention, then you’ll need to source the script before you can execute its procedures:
// Author declared main procedure in "myCommand.mel" as
// global proc performMyCommand()
Finally, if the script in question requires any arguments for its main procedure, you’ll need to read the documentation that came with the script. If there isn’t a separate documentation file then load the MEL script itself into your text editor (or even into the Script Editor). Very often an author will include a description of how to use the script at the top of the file.
For more details regarding the MAYA_SCRIPT_PATH locatoin, refer to Maya’s documentation:
Using Maya → MEL → Introducing Scripting → Setting the Scripting Environment
Maya → Reference → Environment Variables → Setting environment variables using Maya.env
06 Jun 2004