Home | Contents | Prev | Next

MEL Scripting FAQs
Script path FAQs
Calling scripts
How to make Maya look somewhere else for scripts?
What is // Error: line <<XX>>: Cannot find procedure "<<proc name>>"?
How do I add a MEL script to Maya start-up?

How do I add a MEL script to Maya start-up?

How do you add a mel script to the Maya start-up? Say for instance that you want to change defaultRenderGlobals as follows:

setAttr "defaultRenderGlobals.animation" 1;
setAttr "defaultRenderGlobals.extensionPadding" 4;

and you want this to happen for everybody running Maya, but of course without affecting their user preferences.

You tried putting a mel script with the above into the /usr/aw/maya/scripts/startup directory and the /home/$USER/maya/scripts directory, but neither attempt affected Maya on start-up.

To retain preferences that are not saved in the user interface, create a userSetup.mel file in your ~/maya/scripts directory. Whenever you launch Maya, the MEL commands in it are executed. An example command used in the userSetup.mel file would be the following:

alias djs jointDisplayScale;

This creates an alias, djs, that lets you set the joint size without using the Display Joint Size menu or typing jointDisplayScale. You can enter the djs alias with a joint size in the Command Line or Script Editor:

djs 1.5;

The joint size is set to 1.5. You could also set Render globals or other prefs in this file.

The scene is cleared after the commands in the userSetup.mel file are executed. Therefore, any scene elements created using the userSetup.mel file will have been removed when Maya comes up.

Home | Contents | Prev | Next