Maya
Setup for Python


return to main index



Introduction

This tutorial explains how to set up a directory to store custom python scripts such that Maya can source them at start up. It is assumed the scripts will, in the main, be used in conjunction with Mel scripts specifically designed to work with Pixar's RenderMan for Maya (RfM). It is recommended the reader review the tutorial "RfM:Customizing" before applying the suggestions outlined in this tutorial. I am grateful to Fabio Piparo for helping me prepare these notes.


Listing 1 userSetup.mel (Windows & Linux)


if(`about -windows` || `about -linux`) {
    python("import sys");
    python("sys.path.append('$MAYA_APP_DIR/projects/RMS_python')");
    }


Listing 2 userSetup.mel (MacOSX)


python("import sys");
python("sys.path.append('/Users/$USER/Documents/maya/projects/RMS_python')");

Listings 1 and 2 show the Mel code for a file, named userSetup.mel, that should be saved in the maya/scripts directory. For example,

Windows

    M:/maya/scripts/userSetup.mel

Linux

    /home/NAME_OF_USER/maya/scripts/userSetup.mel

MacOSX

    /Users/NAME_OF_USER/Library/Preferences/AutoDesk/maya/scripts/userSetup.mel



Testing

To confirm that Maya is executing userSetup.mel as anticipated, save the script shown in listing 3 into the RMS_python directory. Enter and run the text shown in figure 1 - ensure the Python tab is active! If no errors are reported the RMS_python directory has been set up correctly.


Listing 3 (testRMS_python.py)


def isOK():
    print "Yes"



Figure 1





© 2002- Malcolm Kesson. All rights reserved.