Changing the user script locations with MEL
 
 
 

Maya maintains a list of directories that it searches when it is looking for a script. Maya will search this path when an unknown global procedure is called, or when the "source" command is used.

The search path is stored in an environment variable called MAYA_SCRIPT_PATH. You may set this environment variable in the Maya.env file where your preferences are stored. Or, you may set the environment variable some other way appropriate to the system you are working on.

The value that is stored in MAYA_SCRIPT_PATH is a list of directories, separated by semi-colons on Windows, and by colons on other platforms. For example, you might have the following in your Maya.env file (Mac OS X example):

USER_SCRIPT_PATH = /Volumes/Sapphire/render/scenes/lego pov library/Library:/Volumes/Sapphire/render/scenes/maya/scripts
MAYA_SCRIPT_PATH=$USER_SCRIPT_PATH:$MAYA_SCRIPT_BASE/ scripts/test:$MAYA_SCRIPT_BASE/scripts/unsupported

You can also set the script path temporarily for a session of Maya using the putenv command directly from MEL. For example:

putenv "MAYA_SCRIPT_PATH" "<explicit path>";

It is important to note that the Maya script search path is cached. Maya only scans the path for scripts once on startup, and whenever the MAYA_SCRIPT_PATH variable changes. This means that if a script is added to a directory on the search path while Maya is running, Maya will not automatically find the file. The rehash MEL command tells Maya to rescan the script path and look for new scripts. Caching of the script path improves Maya's performance, especially if parts of the search path are located on network drives.

There is a user directory which Maya always searches for scripts. You can install a script there to have Maya find it, without having to change Maya's script path. This directory's location differs according to your system, but you can always find this directory using the following Maya command:

internalVar -usd
Note

You cannot modify the location of this directory.