I am currently trying to create an interface for a tool I made for Maya.
Here’s the process, problem happen at step 3/.
1/ Every user loads a module loadShelf.py from their userSetup.py
2/ loadShelf.py, which is on the server, creates a shelf. Every button on that shelf loads a different module.py
Exemple: def simmetrizeButton(): import tool_symmetrize imp.reload(tool_symmetrize) tool_symmetrize.symmetrizeWindow() self.addButon("Symmetrize", icon="simmetry_32.png", command=simmetrizeButton)
Pressing the shelf button “Symmetrize” will import tool_symmetrize.py, reload tool_symmetrize.py and launch function tool_symmetrize.symmetrizeWindow().
3/ tool_symmetrize.symmetrizeWindow() will launch a tool with cmds.window. Buttons inside this window will launch function from tool_symmetrize.
Exemple: tool_symmetrize.py: def testA(): print 'test A' cmds.window(....) cmd = "testA()" cmds.button('Launch Test A', command=cmd) cmds.showWindow(....)
The problem is that from a newly opened maya, after succesfully loading tool_symmetry.symmetrizeWindow() from the shelf, calling functions from tool_symmetry.py with the buttons won’t work:
Error: NameError: file line 1:name ‘tool_symmetrize’ is not defined
So… tool_symmetrize.py doesn’t seems to be loaded, but symmetrizeWindow() which works fine is loaded from this very module. I don’t understand.
I tried changing from step 3/ cmd = “testA()” to cmd = “tool_symmetrize.testA()”, but it does not work either.
Can someone help me? I don’t understand how a module clearly loaded by maya can’t be defined when a function from that module call a function from the module.