customizing maya
One of the things that makes maya so powerful is the way it can be customised at so many different levels. The user interface allows you to add tool shelves and marking menus and to designate hot-keys to launch just about any function. The mel scripting language (and more recently python) can be used to create functionality that goes beyond the out-of-the-box set of tools. And an API allows plugins to be written and compiled.
I reckon most people can benefit from customising maya even if all they do is download a few mel scripts from highend3d. This article may be of interest to people just starting out on the path to customised nirvana, and shows how I have configured my environment and where I put stuff. It is written by a maya2008 windows XP user - that's me - and its not the only way to do it, but these things work for me.
INSTALLATION
A default installation puts maya in C:\Program Files\Autodesk\Maya2008. I prefer to reserve the C:\Program Files folder for operating system programs. I make a second partition and logical drive called D: for all non-operating system programs. It stops me messing up my C:drive. So maya goes to D:\Program Files\Autodesk\Maya2008
MAYA_APP_DIR
When you start maya for the first time the default location of the "maya application directory" folder is C:\Documents and Settings\david\My Documents\maya. (Who ever made up the name "Documents and Settings" is probably still laughing. It was a joke - right? Had to be.) The maya application directory is where all your maya preferences get stored and is the default location for your projects folder. Rather than clutter the C: drive with my maya prefs and projects I use a second hard drive, which in my case is on a file server (optional). The file path is K:\david\maya.
I use a windows environment variable called MAYA_APP_DIR to tell maya where to look. This can be set up by right-clicking on "My Computer" and choosing properties to bring up the System Properties window. Then in the advanced tab click "Environment Variables" and then click "New" in the "user variables" section.
Maya.env
Maya trys to be flexible when it comes to folder locations. There are several places it will look by default when searching for things like mel scripts and icons. I dont like to leave things to chance so I use the Maya.env file to specifically define file paths for different things. Maya.env just contains a user specified list of environment variables that are only used by maya.
(note: MAYA_APP_DIR needs to be set in the system properties. All others can be set in Maya.env).
You may have one or more copies of Maya.env which is by default an empty text file. I found them in K:\david\maya and K:\david\maya\2008. I deleted the first one and used the one in K:\david\maya\2008. If you dont have one, just create a text file called Maya.env.
I will explain the actual contents of my Maya.env in the next few sections.
MEL SCRIPTS
Mel scripts are a great way to customize maya. You can write your own or download from a huge selection available online. If you are not careful you can end up in a bit of a mess. You can even upset the core functions of maya. A little organisation goes a long way and will make future trouble-shooting much easier.
Dont believe everything you read! Most, but not all, mel scripts you download will come with some form of installation instruction. It is common to write instructions as comments in the top of the mel file. Sometimes there is a seperate text file. Either way you need to understand a bit about how maya uses mel scripts so that you can decide whether to follow the suggested installation or your own methods instead.
My most important rule is to NEVER put any custom mel script into the maya installation folder.
I use K:\david\maya\2008\scripts as the location for all custom mel scripts. Then I create sub-folders to keep my custom script collection organized. So, for example, K:\david\maya\2008\scripts\comet contains almost 30 scripts written by Michale Comet. K:\david\maya\2008\scripts\djx are the scripts I wrote myself. K:\david\maya\2008\scripts\zoo contains over 170 scripts that make up Hamish McKenzie's zooToolbox. And so on.
K:\david\maya\2008\scripts is one of the places maya will look, by default, for custom scripts, but it will not look into the sub-folders. This is where I use Maya.env to point to the various script locations. I add the following line to Maya.env
MAYA_SCRIPT_PATH = K:\david\maya\2008\scripts;K:\david\maya\2008\scripts\comet;K:\david\maya\2008\scripts\zoo;K:\david\maya\2008\scripts\djx;K:\david\maya\2008\scripts\AE;K:\david\maya\2008\scripts\mods
This configures the MAYA_SCRIPT_PATH environment variable and gives it a list of the script folders. (note: this needs to be a single line in Maya.env, not split over two lines like it appears above)
In fact maya will look for scripts in the local folders specified by the MAYA_SCRIPT_PATH variable before it searches the installation scripts folder. Scripts found in the local scripts folder take precedence over the ones in the installation folders. This is important to know. If you put a script in your local scripts folder with the same name as the one in the installation folder, then the local version over-rides the installation version. This could make maya behave in unexpected ways - or you could use it as a way to tweek and change the way maya works by editing a local copy of a maya script. Then it is easy to revert to the original script if something goes wrong. If maya starts to act strangely you can temporarily rename your local scripts folder, to hide them, and see if the problem is a custom script.
I use K:\david\maya\2008\scripts\mods as the location for scripts from the maya installation that I have modified in some way. In this folder I also keep a text file where I keep a list of the changes I made to each script. When I update the maya installation, I need to check whether my modified scripts are still current, or whether the original scripts were changed in the update. In this case I then need to transfer my modifications to the updated versions of the scripts, and my notes help me remember what I changed in the first place.
ICONS
Often mel scripts create user interfaces that use bitmaps for the buttons and icons. These days, the default location that maya searches for them is K:\david\maya\2008\prefs\icons (although some people still write their mel scripts with special paths hard-coded in the script). When I started using maya it was also common to put bitmaps in a folder called K:\david\maya\bitmaps and I have continued to use that folder. Once again I use Maya.env to tell maya where to look. I add the following line.
XBMLANGPATH = K:\david\maya\bitmaps;K:\david\maya\bitmaps\js;
The example shows two paths; the main bitmaps folder and a sub-folder, called js, where I put the icons for Jan Sandstrom's many mentalray shaders.
PLUGINS
Custom plugins can be a bit of a trap. If you start to rely on them and you update to a new version of maya then you need to also get an update for the plugin. Plugins (unlike mel scripts) must be recompiled for each version of maya. For this reason I am fairly cautious about incorporating plugins into my general work-flow. When I do use them, I put the .mll files in K:\david\maya\2008\plugins
and add the following line to Maya.env
MAYA_PLUG_IN_PATH = K:\david\maya\2008\plugins;
Commercially available plugins usually come with their own installation routine. I still like to make sure I know where the files will end up, and if given a choice I will direct then to somewhere in D:\Program Files\
CUSTOM MENTALRAY SHADERS
Mentalray shaders can have upto 4 different components; a shader called xxx could have these 4 files - xxx.mi, xxx.dll, render_xxx.xpm, AExxxTemplate.mel. Each file needs to be put in the correct location and maya needs to know where it is. Like with mel scripts, I dont like to put custom shaders into the maya installation folders.
I put the xxx.mi in K:\mentalray\include, xxx.dll in K:\mentalray\lib, render_xxx.xpm in my K:\david\maya\bitmaps folder and AExxxTemplate.mel in a sub-folder of my scripts folder called K:\david\maya\2008\scripts\AE (have a look back at my MAYA_SCRIPT_PATH and you will see it listed there).
I define a new environment variable called MI_CUSTOM_SHADER_PATH by adding the following line to Maya.env
MI_CUSTOM_SHADER_PATH = K:\mentalray\lib;K:\mentalray\include;
(note; In versions of maya prior to 8.5 you had to also edit a file called maya.rayrc to declare the shader, but this nolonger required.)
userSetup.mel
When maya starts up it checks your scripts folder and if it finds this mel script it will execute it. This gives you the ability to run mel commands and launch other mel scripts to set up the user interface when you start maya.
My userSetup.mel launches several mel scripts to add menus to maya's main window menu. For example it contains the line
source cometMenu.mel;
which adds a menu that gives me access to a whole bunch of Michael Comet's mel scripts.
Another example is a little work-around for a maya bug where every so often it forgets to load the Mayatomr plugin (aka the mentalray renderer). The following line checks for it and loads it if its not found.
if(!`pluginInfo -query -l -n Mayatomr`) loadPlugin "Mayatomr";
FINISHING UP
What I have written here should be viewed as an example of how one person chose to configure their environment. There are many ways you could do this, and many factors could affect your choices. My main concerns are keeping things organized and keeping things seperate from the default maya installation.
RE: Customizing Maya
I made a mess of it David.
Comment by jeremy — March 15, 2008 @ 10:32 pm
Very useful information. Thanks a lot for explaining this stuff so clearly.
Comment by Skip Jennings — June 14, 2008 @ 7:53 am
hi!
David Johnson
First of all thank you for your selfless dedication, I customizing maya, it is a mel:
if (! `pluginInfo-query-l-n Mayatomr`) loadPlugin "Mayatomr";
When I put it in when loaded into userSetup.mel, maya error:
/ / Error: if (! `PluginInfo-query-l-n Mayatomr`) loadPlugin "Mayatomr";
/ /
/ / Error: "C: / Documents and Settings / li / My Documents/maya/7.0/scripts/userSetup.mel" line 1.52: Syntax error / /
How to solve this problem, thank you
Comment by carli — July 3, 2008 @ 1:40 pm
Oh! I understand that, I made a minor mistake, I put "mayatomr" symbol wrong.
Problem has been resolved!
Comment by carli — July 3, 2008 @ 1:51 pm