Maya python snippets
- September 22nd, 2010
- Write comment
Posting these for my (and anybody else’s) edification – the help docs only get you so far, especially when the nitty gritty of actually *doing* something is more complicated.
Get current shelf:
import maya.cmds as cmds import maya.mel as mel gShelfTopLevel = mel.eval('$temp1=$gShelfTopLevel') print cmds.tabLayout(gShelfTopLevel, query=True, st=True)
Install a menu in the main window menubar:
import maya.cmds as cmds import maya.mel as mel gMainWindow = maya.mel.eval('$temp1=$gMainWindow') oMenu= cmds.menu(parent=gMainWindow, tearOff = True, label = 'MyLabel') subMenu= cmds.menuItem(parent=oMenu, label='mySubMenu', subMenu=True) cmds.menuItem(parent=subMenu, label='MenuItem1', c='somePythonProc()')
Interfaces
This is quite handy.