Hi, I have experience with other 3D software and script languages but I’m kinda new with Maya and Python and I’m having a problem with the userSetup.py.
I’m trying to loading a module with the [userSetup.py].
This module is called [mytoolsLoader] and it is in the same folder(maya/scripts).
This loader [mytoolsLoader] imports another module, called [setProject], and creates an event to execute that module main function.
I want to use this setup so I can add more modules and functions to the loader without having to change the userSetup.py,making it easier to update.
Long story short, it doesn’t work.
If I load [setProject] directly with [userSetup.py], it works.
If I load [setProject] through [mytoolsLoader], it doesn’t.
If I import the [setProject] module in [userSetup.py] but still execute it and create an event with [mytoolsLoader], it works.
and I have no idea why. What am I doing wrong?
This is how I’d like to do it, but doesn’t work:
userSetup.py inside maya/scripts
#userSetup.py
import mytoolsLoader
mytoolsLoader.main()
toolsLoader.py inside maya/scripts
#toolsLoader
from maya import cmds
from mytools import setProject
def main():
cmds.scriptJob( event=("SceneOpened", "setProject.main()") )
setProject.py inside the mytools folder (maya/scripts/mytools)
#setProject
def main():
code........
So to make it work, I’ve added “from mytools import setProject” to my userSetup.py as a workaround.