adding to the default Maya menu overwrites the whole menu
When you add a menu item to a default Maya menu (e.g. Windows, Mesh, File, …) on startup, it overwrites the whole menu.
There’s a partial fix that works for some menus.
Run this before adding to the Maya menu to avoid overwriting the whole menu.
but this only supports strign commands. no callables.
# As Maya builds its menus dynamically upon being accessed,
# we force its build here prior to adding our entry using it's
# native mel function call.
mel.eval("evalDeferred buildFileMenu")
# use maya.utils.executeDeferred for callables
# or use maya.cmds.evalDeferred for strings
maya.utils.executeDeferred(add_to_menu)
depending which menu, run a different build command
| menu name | command name |
|---|---|
| File | buildFileMenu |
| Windows | ?? there seems to be in ViewMenu but not workingThere’s no buildWindowsMenutried mel.eval('evalDeferred "source ViewMenu;"') no luck |
| Display | ?? test buildDisplayMenu |
| ?? buildHelpMenu |
Pyblish Maya handles this
adding itself to the File menu, but the same doesn’t work for the window
RnD to add to maya windows menu on startup
Backlinks¶
- unimenu
- it has different implementations for each app.
- Pyblish Maya plugin
- it handles adding to the default Maya menu overwrites the whole menu correctly
- Maya module manager
- module manager overwrites the maya menu Maya menu