本文整理匯總了Python中maya.cmds.menuItem方法的典型用法代碼示例。如果您正苦於以下問題:Python cmds.menuItem方法的具體用法?Python cmds.menuItem怎麽用?Python cmds.menuItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類maya.cmds
的用法示例。
在下文中一共展示了cmds.menuItem方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __mirror_flip_pose_callback
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import menuItem [as 別名]
def __mirror_flip_pose_callback(*args):
"""Wrapper function to call mGears mirroPose function
Args:
list: callback from menuItem
"""
# cast controls into pymel object nodes
controls = [pm.PyNode(x) for x in args[0]]
# triggers mirror
# we handle the mirror/flip each control individually even if the function
# accepts several controls. Flipping on proxy attributes like blend
# attributes cause an issue to rather than trying the complete list we do
# one control to avoid the mirror to stop
for ctl in controls:
mirrorPose(flip=args[1], nodes=[ctl])
示例2: __reset_attributes_callback
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import menuItem [as 別名]
def __reset_attributes_callback(*args):
""" Wrapper function to call mGears resetTransform function
Args:
list: callback from menuItem
"""
attribute = args[1]
for node in args[0]:
control = pm.PyNode(node)
if attribute == "translate":
resetTransform(control, t=True, r=False, s=False)
if attribute == "rotate":
resetTransform(control, t=False, r=True, s=False)
if attribute == "scale":
resetTransform(control, t=False, r=False, s=True)
示例3: __init__
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import menuItem [as 別名]
def __init__(self, title, help_url=None):
layout = mel.eval("getOptionBox")
cmds.setParent(layout)
mel.eval('setOptionBoxTitle("{}");'.format(title))
self.create_ui()
apply_close_button = mel.eval("getOptionBoxApplyAndCloseBtn;")
cmds.button(apply_close_button, e=True, command=self._apply_and_close)
apply_button = mel.eval("getOptionBoxApplyBtn;")
cmds.button(apply_button, e=True, command=self._on_apply)
close_button = mel.eval("getOptionBoxCloseBtn;")
cmds.button(close_button, e=True, command=self._close)
if help_url:
help_item = mel.eval("getOptionBoxHelpItem;")
cmds.menuItem(
help_item,
e=True,
label="Help on {}".format(title),
command='import webbrowser; webbrowser.open("{}")'.format(help_url),
)
示例4: markingMenu
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import menuItem [as 別名]
def markingMenu():
'''
Example of how a marking menu could be set up.
'''
menuKwargs = {'enable':True,
'subMenu':False,
'enableCommandRepeat':True,
'optionBox':False,
'boldFont':True}
mc.menuItem(radialPosition='NW', label='Trans', command=translate, **menuKwargs)
mc.menuItem(radialPosition='N', label='Rot', command=rotate, **menuKwargs)
mc.menuItem(radialPosition='NE', label='Scale', command=scale, **menuKwargs)
mc.menuItem(radialPosition='SW', label='X', command=x, **menuKwargs)
mc.menuItem(radialPosition='S', label='Y', command=y, **menuKwargs)
mc.menuItem(radialPosition='SE', label='Z', command=z, **menuKwargs)
mc.menuItem(radialPosition='W', label='ChanBox', command=channelBox, **menuKwargs)
mc.menuItem(radialPosition='E', label='Sel', command=selected, **menuKwargs)
mc.menuItem(label='All', command=showAll, **menuKwargs)
示例5: attributeMenuItem
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import menuItem [as 別名]
def attributeMenuItem(node, attr):
plug = node+'.'+attr
niceName = mc.attributeName(plug, nice=True)
#get attribute type
attrType = mc.getAttr(plug, type=True)
if attrType == 'enum':
listEnum = mc.attributeQuery(attr, node=node, listEnum=True)[0]
if not ':' in listEnum:
return
listEnum = listEnum.split(':')
mc.menuItem(label=niceName, subMenu=True)
for value, label in enumerate(listEnum):
mc.menuItem(label=label, command=partial(mc.setAttr, plug, value))
mc.setParent('..', menu=True)
elif attrType == 'bool':
value = mc.getAttr(plug)
label = 'Toggle '+ niceName
mc.menuItem(label=label, command=partial(mc.setAttr, plug, not value))
示例6: markingMenu
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import menuItem [as 別名]
def markingMenu():
'''
Example of how a marking menu could be set up.
'''
menuKwargs = {'enable':True,
'subMenu':False,
'enableCommandRepeat':True,
'optionBox':False,
'boldFont':True}
mc.menuItem(radialPosition='N', label='Trace Camera', command=traceCamera, **menuKwargs)
mc.menuItem(radialPosition='E', label='Trace World', command=traceWorld, **menuKwargs)
mc.menuItem(radialPosition='W', label='Re-Trace', command=retraceArc, **menuKwargs)
mc.menuItem(radialPosition='S', label='Clear', command=clearArcs, **menuKwargs)
mc.menuItem(label='Arc Tracer UI', command=ui, **menuKwargs)
示例7: getItem
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import menuItem [as 別名]
def getItem(item, name, parents):
"""
Get data from item and store it into COMMANDS variable.
:param QWidgetAction item:
:param str name:
:param list parents: List f all parents, used for hierarchy
"""
# get name
text = item.text().encode("utf-8")
if not name or item.isSeparator() or item.menu():
return
# add last parent
parents.append(text)
# get icon
icon = cmds.menuItem(utils.qtToMaya(item), query=True, image=True)
# store commands
COMMANDS[name] = dict( )
COMMANDS[name]["name"] = text
COMMANDS[name]["pin"] = False
COMMANDS[name]["cmd"] = item
COMMANDS[name]["icon"] = utils.QIcon( ":/{0}".format(icon))
COMMANDS[name]["group"] = parents[0]
COMMANDS[name]["search"] = "".join([p.lower() for p in parents])
COMMANDS[name]["hierarchy"] = " > ".join(parents)
示例8: _update_menu_task_label
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import menuItem [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)
示例9: getCurrentMenuValue
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import menuItem [as 別名]
def getCurrentMenuValue(self, itemList, *args):
for item in itemList:
if cmds.menuItem( item+"_MI", query=True, radioButton=True ):
return item
示例10: reCreateEditSelectedModuleLayout
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import menuItem [as 別名]
def reCreateEditSelectedModuleLayout(self, bSelect=False, *args):
Layout.LayoutClass.reCreateEditSelectedModuleLayout(self, bSelect)
# style layout:
self.styleLayout = cmds.rowLayout(numberOfColumns=4, columnWidth4=(100, 50, 50, 70), columnAlign=[(1, 'right'), (2, 'left'), (3, 'right')], adjustableColumn=4, columnAttach=[(1, 'both', 2), (2, 'left', 2), (3, 'left', 2), (3, 'both', 10)], parent="selectedColumn")
cmds.text(label=self.langDic[self.langName]['m041_style'], visible=True, parent=self.styleLayout)
self.styleMenu = cmds.optionMenu("styleMenu", label='', changeCommand=self.changeStyle, parent=self.styleLayout)
styleMenuItemList = [self.langDic[self.langName]['m042_default'], self.langDic[self.langName]['m026_biped']]
for item in styleMenuItemList:
cmds.menuItem(label=item, parent=self.styleMenu)
# read from guide attribute the current value to style:
currentStyle = cmds.getAttr(self.moduleGrp+".style")
cmds.optionMenu(self.styleMenu, edit=True, select=int(currentStyle+1))
示例11: __change_rotate_order_callback
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import menuItem [as 別名]
def __change_rotate_order_callback(*args):
"""Wrapper function to call mGears change rotate order function
Args:
list: callback from menuItem
"""
# triggers rotate order change
change_rotate_order(args[0], args[1])
示例12: __keyframe_nodes_callback
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import menuItem [as 別名]
def __keyframe_nodes_callback(*args):
"""Wrapper function to call Maya's setKeyframe command on given controls
Args:
list: callback from menuItem
"""
cmds.setKeyframe(args[0])
示例13: __select_nodes_callback
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import menuItem [as 別名]
def __select_nodes_callback(*args):
""" Wrapper function to call Maya select command
Args:
list: callback from menuItem
"""
cmds.select(args[0], add=True)
示例14: install
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import menuItem [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)
示例15: makeMenu
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import menuItem [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
# ----------------------------------------------------------------------