mgear4
mgear4 copied to clipboard
mGear menu deleteUI bug
While trying to debug the menu not loading correctly with this error in maya 2022:
// # RuntimeError: deleteUI: Object ‘mGear’ not found.
I found a little more context to the actual error. It appears it's actually a pymel bug. On a fresh start the very first time you call pm.menu it parses the return value incorrectly and returns an invalid object.
# Result: ui.Menu('graphEditorWindow|graphEditor1|False') #
Subsequent calls to pm.menu return a boolean as expected. Interestingly if you invoke it this way
pm.menu('mGear2', exists=True, query=True)
then it always seems to return the correct type, even on a fresh start. Either of the equivalent cmds calls also always seem to return the correct type.
cmds.menu('mGear2', exists=True) cmds.menu('mGear2', exists=True, query=True)
So if you avoid the bugged call then you shouldn't need a blind try/catch in menu.create