Bug: Python nameCommand only supports mel commands

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
For Maya 2018, in Python, I have the following code, to create a menu item called "Save New Version" in the main file menu.
import pymel.core as pm
import maya.mel as mel
mel.eval('buildFileMenu') saveNewVersionCmd = '\nimport fl_saveNewVersion\nreload(fl_saveNewVersion)\nfl_saveNewVersion.saveNewVersion()\n' pm.menuItem(l='Save New Version', ann="Save new version", c=saveNewVersionCmd, ia='saveAsOptions', parent='mainFileMenu') pm.nameCommand('saveNewVersionNameCmd', ann="Save new version", stp='python', c=saveNewVersionCmd) pm.hotkey(k='s', cmd=True, ctl=True, name='saveNewVersionNameCmd')
When I run this, the item shows in the menu and it works. But the hotkey doesn't work because, in the nameCommand, the python code in the saveNewVersionCmd string is interpreted as mel, even though the stp flag in the nameCommand is 'python'. I have checked this by replacing the code in saveNewVersionCmd with mel code. When I run that, the menu command breaks but the hotkey works. In order to get both the menu command and the hotkey to work at once, I've had to implement the following workaround, formatting the saveNewVersionCmd string as mel rather than as python, and specifying 'mel' for both the menuItem command and the nameCommand:
import pymel.core as pm import maya.mel as mel mel.eval('buildFileMenu') saveNewVersionCmd = 'python("\\nimport fl_saveNewVersion\\nreload(fl_saveNewVersion)\\nfl_saveNewVersion.saveNewVersion()\\n")' pm.menuItem(l='Save New Version', ann="Save new version", stp='mel', c=saveNewVersionCmd, ia='saveAsOptions', parent='mainFileMenu') pm.nameCommand('saveNewVersionNameCmd', ann="Save new version", stp='mel', c=saveNewVersionCmd) pm.hotkey(k='s', cmd=True, ctl=True, name='saveNewVersionNameCmd')
The stp flag in the nameCommand is just not working. I have tried this with maya.cmds as well as PyMel, and also Mel. In all three, the stp flag is ignored and the command is interpreted as mel.
I am reporting this as a bug, in addition to posting it here.