userSetup.py UI creation problems

276 views
Skip to first unread message

Lidia Martinez

unread,
Feb 26, 2015, 6:50:47 AM2/26/15
to python_in...@googlegroups.com

I delete a shelf tab and add the same tab, updating the contents.

The problem is that executing the code works inside Maya, but executing the code under userSetup.py, the global MEL variable:

$gShelfTopLevel

That holds the path to the shelf,. But when executing the script, it is EMPTY. So the script deleteShelfTab and everything else i do, doesn't work...

Why doesn't it work?



Failed to execute userSetup.py
Traceback (most recent call last):
  File "C:/Users/lmartinez/Documents/maya/scripts\userSetup.py", line 15, in <module>
    utils.executeDeferred(mayaInitScript.mayaInitScript())
  File "R:\resource\technical\maya\mayaInitScript.py", line 29, in mayaInitScript
    mel.eval("deleteShelfTab \"" + shelfName + "\"")
RuntimeError: Error occurred during execution of MEL script
file: C:/winapp/3d/Maya2015/scripts/others/deleteShelfTab.mel line 57: setParent: Object '' not found.



This works on an opened Maya. But this variable seems to be holding and empty string...
I do nothing with it before this.


--
Lidia

Tony Barbieri

unread,
Feb 26, 2015, 9:22:51 AM2/26/15
to python_in...@googlegroups.com
Hello Lidia,

The issue is userSetup is run before the Maya UI has been created.  You could try executing your command inside userSetup.py using cmds.evalDeferred which I believe will work.  

Best,

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAAB1%3D8ws0ukzDeBvEW7HfZ%3DT%3DG_7UGK%3DSNN-%3D6L9KB-Scd1KeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Tony

Lidia Martinez

unread,
Feb 26, 2015, 9:27:25 AM2/26/15
to python_in...@googlegroups.com
Yeah. That's it. I fixed it that way. 
And the problem was that i was calling deferred( nameFunction() )   with those "()". You have to remove them instead.

Now it works. But took me a while to get it working.

--
Lidia

Reply all
Reply to author
Forward
0 new messages