Friday, 13 January 2012

Maya: Starting scripts on load - userSetup.mel

To execute scripts, whether custom or local, each time you startup maya (in the studio ours check important prefs, timeUnits etc) is very simple.

All you need to do is create a mel script called "userSetup.mel" and place it into you maya/scripts folder in your documents (of course there are instances, depending on what the script is doing, if its messing with mainWindow states etc, you need to make sure they load first by using the "evalDeferred" command - at least that's what I've come to believe.

For example if you created a mel script like this;
string $win=`window` ; columnLayout -adj true ; text -label "Hello World" -align "center" ; setParent.. ; showWindow $win ;
called it "userSetup.mel" and placed it into maya/scripts/  folder, on starting maya, you can expect to see a window with the text "Hello World" pop up when maya starts.
Generally this idea is taken further (if in a studio) and either each user's environment vars point to a userSetup.mel on the network, or each have their own userSetup.mel on their local machine that points to a separate startup script on the network, which then its fairly simple for the user to modify their own startup, based on their preferences.

At some point, once I get some time, I do intend on revisiting and furthering most of my posts, taking the time to actually explain what's going on and why, and giving links the right documentation.

Comments welcome.

No comments:

Post a Comment