run a script on startup


#1

Hey guys,
I just want to know if there is any other method to run a script on each time maya loads without using userSetup.mel or userSetup.py? I think you can do it with command line but can I know how to automate it on each maya load?

This is to deploy the tools and right now i am doing with userSetup.mel. Will modules be useful to deploy tools from a generic location without touching userSetup or maya.env? Help will be much appreciated.

Thanks


#2

you can pass maya a mel script to run on startup using the command line.

this is the method we use to load our custom tools.

I recommend writing a simple batch file to set PYTHONPATH and MAYA_SCRIPT_PATH, etc, to your tool location and then calling maya.exe.

then provide your users with a new maya desktop shortcut to place alongside the standard maya shortcut.

this allows you to still run the standard maya, which can helpful for determining if a bug is related to your changes or inherent in maya.


#3

With modules you cannot load anything, it only offers a way to setup all necessary paths and variables. But from a user point of view, I don’t like tools which loads automatically at startup without control.

You could write a simple python plugin if you do not have another plugin anyway and load everything that’s needed in this plugin similiar to the way a renderer loads all necessary tools. This way the user has complete control. If he loads the plugin or autoloads it, the plugin is loaded and does all necessary procedures. If he doesnt want it it any more he simply turn off the plugin.


#4

Thanks a lot for the replies guys.
@rgkovach123: I have read this by you in an other thread already and fairly impressed. Right now I am doing with batch file only but wrting to userSetup to run the script on each maya load. But I dint get a clue how can I run the script from command line on each maya start up. Can you be a little more elaborate on how to do it, if you don’t mind. Thanks


#5

and more over, the script I am running will create a menu, So, could running maya from command line do it? as there won’t be any menu available by then.


#6

the simplest case would look something like this (untested):


set MAYA_SCRIPT_PATH=C:\MyScripts
start "c:\program files\autodesk\maya2016\bin\maya.exe" -command "myStartupScript"


#7

An alternative approach with minimal local setup is to use Maya.env
Give every user a local copy of Maya.env that contains just one line…

PYTHONPATH = X:\sharedUserSetup

…where the path is your shared network location. And in the shared folder put userSetup.py which you use to setup everything else.

For users that want to customize their environment we let them create something called localUserSetup.py. Our shared userSetup will check for localUserSetup and run it if it exists.

David


#8

a valid approach, I try to avoid modifying maya’s default behavior so I can always rely on the default maya icon to launch an un-tainted maya session.

granted, I have the luxury of piggy-backing my startup bootstrap onto an existing delivery mechanism that distributes all of our development tools.