Share
 
 

Save your script and call a procedure from your script

Save your script to the shelf or marking menu

For better accessibility, you can save your scripts or commonly used runtime commands to the shelf, or to the marking menu.

Middle-drag your script or command to the shelf to save it. See Make a shelf button for a script.

To create a custom marking menu with your script

  1. Select Windows > Settings/Preferences > Marking Menu Editor.

    Click Create Marking Menu to create a new marking menu.

  2. Middle-drag the runtime command or script that you want to add to the Create Marking Menu window.

Save your script as a MEL file and call its procedures

Do either of the following:

  • Save your script with your command name as its filename and .mel as its file extension (for example myCommand.mel for the command myCommand) to a folder in your MAYA_SCRIPT_PATH.

    If you choose this method, and your .mel file contains more than one global procedure, you must call myCommand before you call other global procedures in your file. Therefore, this may not be your preferred method in this case.

  • Save your script with any filename and source it with the source command.

    After a script is sourced, you can call any of its global procedures and in any order.

  • Note: If you are unsure whether you need to source your script, you can first test if your function is available in MEL before calling it:
    If (!`exists myFunction`) 
        source myFile;
    myFunction;
    

Related topics

Was this information helpful?