本文整理汇总了Python中maya.cmds.menu方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.menu方法的具体用法?Python cmds.menu怎么用?Python cmds.menu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maya.cmds
的用法示例。
在下文中一共展示了cmds.menu方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: install
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def install():
"""Install Maya-specific functionality of avalon-core.
This function is called automatically on calling `api.install(maya)`.
"""
# Inherit globally set name
self._menu = api.Session["AVALON_LABEL"] + "menu"
_register_callbacks()
_register_events()
_set_project()
# Check if maya version is compatible else fix it, Maya2018 only
# Should be run regardless of batch mode
compat.install()
if not IS_HEADLESS:
_install_menu()
pyblish.register_host("mayabatch")
pyblish.register_host("mayapy")
pyblish.register_host("maya")
示例2: run
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def run(*args, **kwargs): # @UnusedVariable
""" Menu run execution
Args:
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
"""
# get check-box state
state = args[0]
if state:
cmds.optionVar(intValue=("mgear_dag_menu_OV", 1))
else:
cmds.optionVar(intValue=("mgear_dag_menu_OV", 0))
# runs dag menu right click mgear's override
mgear_dagmenu_toggle(state)
示例3: initializeMenu
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def initializeMenu(self, entries):
try:
# gMainWindow = MayaInterop.main_parent_window()
gMainWindow = maya.mel.eval('$temp1=$gMainWindow')
except RuntimeError as e:
print e
print 'Are you running in Batch Python?'
gMainWindow = None
try:
print 'Initialising menu...'
self.perforceMenu = cmds.menu("PerforceMenu", parent=gMainWindow, tearOff=True, label='Perforce')
cmds.setParent(self.perforceMenu, menu=True)
except RuntimeError as e:
print 'Maya error while trying to create menu:',
print e
示例4: buttonWithPopup
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def buttonWithPopup(self, label=None, command=None, annotation='', shelfLabel='', shelfIcon='render_useBackground', readUI_toArgs={}):
'''
Create a button and attach a popup menu to a control with options to create a shelf button or a hotkey.
The argCommand should return a kwargs dictionary that can be used as args for the main command.
'''
if self.icon:
shelfIcon = self.icon
if annotation and not annotation.endswith('.'):
annotation+='.'
button = mc.button(label=label, command=command, annotation=annotation+' Or right click for more options.')
mc.popupMenu()
self.shelfMenuItem(command=command, annotation=annotation, shelfLabel=shelfLabel, shelfIcon=shelfIcon)
self.hotkeyMenuItem(command=command, annotation=annotation)
return button
示例5: _uninstall_menu
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def _uninstall_menu():
# In Maya 2020+ don't use the QApplication.instance()
# during startup (userSetup.py) as it will return a
# QtCore.QCoreApplication instance which does not have
# the allWidgets method. As such, we call the staticmethod.
all_widgets = QtWidgets.QApplication.allWidgets()
widgets = dict((w.objectName(), w) for w in all_widgets)
menu = widgets.get(self._menu)
if menu:
menu.deleteLater()
del(menu)
示例6: _update_menu_task_label
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def _update_menu_task_label():
"""Update the task label in Avalon menu to current session"""
if IS_HEADLESS:
return
object_name = "{}|currentContext".format(self._menu)
if not cmds.menuItem(object_name, query=True, exists=True):
logger.warning("Can't find menuItem: {}".format(object_name))
return
label = "{}, {}".format(api.Session["AVALON_ASSET"],
api.Session["AVALON_TASK"])
cmds.menuItem(object_name, edit=True, label=label)
示例7: changeOptionDegree
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def changeOptionDegree(self, degreeOption, *args):
""" Set optionVar to choosen menu item.
"""
cmds.optionVar(stringValue=('dpAutoRigLastDegreeOption', degreeOption))
self.degreeOption = int(degreeOption[0])
示例8: get_option_var_state
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def get_option_var_state():
""" Gets dag menu option variable
Maya's optionVar command installs a variable that is kept on Maya's
settings so that you can use it on future sessions.
Maya's optionVar are a quick and simple way to store a custom variable on
Maya's settings but beware that they are kept even after mGear's uninstall
so you will need to run the following commands.
Returns:
bool: Whether or not mGear's dag menu override is used
Example:
The following removes mgears dag menu optionVar
.. code-block:: python
from maya import cmds
if not cmds.optionVar(exists="mgear_dag_menu_OV"):
cmds.optionVar(remove="mgear_dag_menu_OV")
"""
# if there is no optionVar the create one that will live during maya
# current and following sessions
if not cmds.optionVar(exists="mgear_dag_menu_OV"):
cmds.optionVar(intValue=("mgear_dag_menu_OV", 0))
return cmds.optionVar(query="mgear_dag_menu_OV")
示例9: install
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def install():
""" Installs dag menu option
"""
# get state
state = get_option_var_state()
cmds.setParent(mgear.menu_id, menu=True)
cmds.menuItem("mgear_dagmenu_menuitem", label="mGear Viewport Menu ",
command=run, checkBox=state)
cmds.menuItem(divider=True)
run(state)
示例10: mgear_dagmenu_callback
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def mgear_dagmenu_callback(*args, **kwargs): # @UnusedVariable
""" Triggers dag menu display
If selection is ends with **_ctl** then display mGear's contextual menu.
Else display Maya's standard right click dag menu
Args:
*args: Parent Menu path name / Variable length argument list.
**kwargs: Arbitrary keyword arguments.
Returns:
str: Menu object name/path that is passed to the function
"""
# cast args into more descend variable name
parent_menu = args[0]
# if second argument if not a bool then means that we are running
# the override
if type(args[1]) != bool:
sel = cmds.ls(selection=True, long=True, exactType="transform")
if sel and cmds.objExists("{}.isCtl".format(sel[0])):
# cleans menu
_parent_menu = parent_menu.replace('"', '')
cmds.menu(_parent_menu, edit=True, deleteAllItems=True)
# fills menu
mgear_dagmenu_fill(_parent_menu, sel[0])
else:
mel.eval("buildObjectMenuItemsNow " + parent_menu)
# always return parent menu path
return parent_menu
示例11: removeMenu
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def removeMenu(menuName=kPluginCmdName):
"""remove menu when plugin unload"""
if cmds.menu(menuName, q=True, exists=True):
cmds.deleteUI(menuName, menu=True)
示例12: makeMenu
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def makeMenu(menuName=kPluginCmdName):
"""make menu when plugin load"""
removeMenu(menuName)
topMenu = cmds.menu(menuName, label=menuName, parent=u'MayaWindow', tearOff=True)
cmds.menuItem(label=kPluginCmdName, parent=topMenu, command=kPluginCmdName, sourceType='mel')
# Plugin class
# ----------------------------------------------------------------------
示例13: initializePlugin
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def initializePlugin(mobject):
"""Initialize the plug-in and add menu"""
errMsg = u'Failed to register command: %s\n' % kPluginCmdName
plugin = om.MFnPlugin(mobject, kPluginVendor, kPluginVersion)
try:
plugin.registerCommand(kPluginCmdName, MyDemo.creator)
makeMenu(menuName=kPluginCmdName)
# makeShelf(shelfName=kPluginCmdName)
except:
sys.stderr.write(errMsg)
raise
# Uninitialize
# ----------------------------------------------------------------------
示例14: uninitializePlugin
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def uninitializePlugin(mobject):
"""Uninitialize the plug-in and delete menu"""
plugin = om.MFnPlugin(mobject)
try:
plugin.deregisterCommand(kPluginCmdName)
removeMenu(menuName=kPluginCmdName)
# removeShelf(shelfName=kPluginCmdName)
except:
sys.stderr.write('Failed to unregister command: %s\n' % kPluginCmdName)
raise
示例15: createUI
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import menu [as 别名]
def createUI():
cmds.setParent('MayaWindow')
try:
cmds.menu('MukaiLab', query = True, label = True)
except:
cmds.menu('MukaiLab', label = 'MukaiLab')
cmds.setParent('MukaiLab', menu = True)
cmds.menuItem('SSDS', label = 'SSDS', command = showBuildWindow)