Executing a script at startup

Hi

I'm trying to execute this script at startup, I'v looked everywhere on the maya docs but for some strange reason it will not work. Thanks.

setAttr "lambert1.color" -type double3 1 1 1 ;
setAttr "lambert1.transparency" -type double3 0.18182 0.18182 0.18182 ;

If you include that code in usersetup.mel, it'll be run as part of the startup procedure. But this probably doesn't work, since creating a new document happens after all the initialization, and would overwrite any effects.

scriptJob does nicely for "do this every time something happens" stuff -- like every time I start a new document.

Try this: (haven't tested it -- I'm not in front of Maya)

global proc setupLambert1() {
setAttr "lambert1.color" -type double3 1 1 1 ;
setAttr "lambert1.transparency" -type double3 0.18182 0.18182 0.18182 ;
}
scriptJob -e "NewSceneOpened" "setupLambert1";

Put that in usersetup.mel -- in your scripts dir -- My Documents/Maya/scripts/ -- and it'll take care of it.

I've broken one of the cardinal rules of scriptJobs though. I haven't given it a parent or any way to kill it. So, it'll do it every time a new document is opened -- whether you like it or not. If you ever want to disable it, comment out the scriptJob line, or rename usersetup.mel and restart Maya. Or delete the scriptJob manually.

Rob Richardson

Hi Rob

You know whats funny, I try putting a userSetup.mel with the scripts (the setAttr only) and it did not worked. Now with your scripts works perfect, even when I create a new scene (just what I wanted). Still I wonder why it doesn't work alone as below. Thank you again...

setAttr "lambert1.color" -type double3 1 1 1 ;

setAttr "lambert1.transparency" -type double3 0.18182 0.18182 0.18182 ;

maya executes your lines at startup, but perhaps one of the last things maya does at startup is to create a new empty scene. So your changes get changed back before you can see it.

Ahh well clear enough. Thanks all for the help.

exactly so. Maya creates it's menus, it's editors, etc. It loads the usersetup.mel as part of this process. Then it creates a new scene (or opens a scene). It'd be hard to open the scene if it hadn't loaded the procedures for dealing with the geometry.

So, why doesn't it work to just put the commands in usersetup.mel? The shader you're trying to change hasn't been created yet.

Rob Richardson