當前位置: 首頁>>代碼示例>>Python>>正文


Python cmds.menuItem方法代碼示例

本文整理匯總了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]) 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:19,代碼來源:dagmenu.py

示例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) 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:20,代碼來源:dagmenu.py

示例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),
            ) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:23,代碼來源:optionbox.py

示例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) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:25,代碼來源:ml_graphEditorMask.py

示例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)) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:23,代碼來源:ml_puppet.py

示例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) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:19,代碼來源:ml_arcTracer.py

示例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) 
開發者ID:robertjoosten,項目名稱:maya-command-search,代碼行數:31,代碼來源:commands.py

示例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) 
開發者ID:getavalon,項目名稱:core,代碼行數:16,代碼來源:pipeline.py

示例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 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:6,代碼來源:dpAutoRig.py

示例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)) 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:14,代碼來源:dpSpine.py

示例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]) 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:11,代碼來源:dagmenu.py

示例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]) 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:10,代碼來源:dagmenu.py

示例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) 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:10,代碼來源:dagmenu.py

示例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) 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:15,代碼來源:dagmenu.py

示例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
# ---------------------------------------------------------------------- 
開發者ID:WendyAndAndy,項目名稱:MayaDev,代碼行數:11,代碼來源:pyMyPlugin.py


注:本文中的maya.cmds.menuItem方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。