当前位置: 首页>>代码示例>>Python>>正文


Python cmds.channelBox方法代码示例

本文整理汇总了Python中maya.cmds.channelBox方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.channelBox方法的具体用法?Python cmds.channelBox怎么用?Python cmds.channelBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.channelBox方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getChannelBoxMenu

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import channelBox [as 别名]
def getChannelBoxMenu():
    """
    Get ChannelBox, convert the main channel box to QT and return the QMenu 
    which is part of the channel box' children.

    :return: Maya's main channel box menu
    :rtype: QMenu
    """
    channelBox = getChannelBox()
    
    for child in channelBox.children():
        if type(child) == QMenu:
            cmd = "generateChannelMenu {0} 1".format(qtToMaya(child))
            mel.eval(cmd)
            return child


# ---------------------------------------------------------------------------- 
开发者ID:robertjoosten,项目名称:maya-channel-box-plus,代码行数:20,代码来源:ui.py

示例2: getSelectedChannels

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import channelBox [as 别名]
def getSelectedChannels():
    '''
    Return channels that are selected in the channelbox
    '''

    if not mc.ls(sl=True):
        return
    gChannelBoxName = mm.eval('$temp=$gChannelBoxName')
    sma = mc.channelBox(gChannelBoxName, query=True, sma=True)
    ssa = mc.channelBox(gChannelBoxName, query=True, ssa=True)
    sha = mc.channelBox(gChannelBoxName, query=True, sha=True)

    channels = list()
    if sma:
        channels.extend(sma)
    if ssa:
        channels.extend(ssa)
    if sha:
        channels.extend(sha)

    return channels 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:23,代码来源:ml_utilities.py

示例3: _populateSelectionField

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import channelBox [as 别名]
def _populateSelectionField(self, channel, field, *args):

        selectedChannels = None
        if channel:
            selectedChannels = getSelectedChannels()
            if not selectedChannels:
                raise RuntimeError('Please select an attribute in the channelBox.')
            if len(selectedChannels) > 1:
                raise RuntimeError('Please select only one attribute.')

        sel = mc.ls(sl=True)
        if not sel:
            raise RuntimeError('Please select a node.')
        if len(sel) > 1:
            raise RuntimeError('Please select only one node.')

        selection = sel[0]
        if selectedChannels:
            selection = selection+'.'+selectedChannels[0]

        mc.textFieldButtonGrp(field, edit=True, text=selection) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:23,代码来源:ml_utilities.py

示例4: _populateSelectionList

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import channelBox [as 别名]
def _populateSelectionList(self, channel, control, *args):

        selectedChannels = None
        if channel:
            selectedChannels = getSelectedChannels()
            if not selectedChannels:
                raise RuntimeError('Please select an attribute in the channelBox.')
            if len(selectedChannels) > 1:
                raise RuntimeError('Please select only one attribute.')

        sel = mc.ls(sl=True)
        if not sel:
            raise RuntimeError('Please select a node.')
        if len(sel) > 1:
            raise RuntimeError('Please select only one node.')

        selection = sel[0]
        if selectedChannels:
            selection = selection+'.'+selectedChannels[0]

        mc.textScrollList(control, edit=True, append=[selection]) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:23,代码来源:ml_utilities.py

示例5: setNonKeyable

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import channelBox [as 别名]
def setNonKeyable(self, objList, attrList, *args):
        """Set nonKeyable to attributes for objects in lists.
        """
        if objList and attrList:
            for obj in objList:
                for attr in attrList:
                    if cmds.objExists(obj+"."+attr):
                        try:
                            # set lock and hide of given attributes:
                            cmds.setAttr(obj+"."+attr, keyable=False, channelBox=True)
                        except:
                            print "Error: Cannot set", obj, ".", attr, "as nonKeayble, sorry." 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:14,代码来源:dpControls.py

示例6: copyAttr

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import channelBox [as 别名]
def copyAttr(self, sourceItem=False, attrList=False, verbose=False, *args):
        """ Get and store in a dictionary the attributes from sourceItem.
            Returns the dictionary with attribute values.
        """
        # getting sourceItem:
        if not sourceItem:
            selList = cmds.ls(selection=True, long=True)
            if selList:
                sourceItem = selList[0]
            else:
                print self.dpUIinst.langDic[self.dpUIinst.langName]["e015_selectToCopyAttr"]
        if cmds.objExists(sourceItem):
            if not attrList:
                # getting channelBox selected attributes:
                currentAttrList = cmds.channelBox('mainChannelBox', query=True, selectedMainAttributes=True)
                if not currentAttrList:
                    # list all attributes if nothing is selected:
                    currentAttrList = cmds.listAttr(sourceItem, visible=True, keyable=True)
                attrList = currentAttrList
            if attrList:
                # store attribute values in a dic:
                self.attrValueDic = {}
                for attr in attrList:
                    if cmds.objExists(sourceItem+'.'+attr):
                        value = cmds.getAttr(sourceItem+'.'+attr)
                        self.attrValueDic[attr] = value
                if verbose:
                    print self.dpUIinst.langDic[self.dpUIinst.langName]["i125_copiedAttr"]
        return self.attrValueDic 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:31,代码来源:dpControls.py

示例7: getChannelBox

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import channelBox [as 别名]
def getChannelBox():
    """
    Get ChannelBox, convert the main channel box to QT.

    :return: Maya's main channel box
    :rtype: QWidget
    """
    channelBox = mayaToQT(CHANNELBOX)
    return channelBox 
开发者ID:robertjoosten,项目名称:maya-channel-box-plus,代码行数:11,代码来源:ui.py

示例8: updateSearch

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import channelBox [as 别名]
def updateSearch(self, matchString, nodes):    
        """
        Loop over all keyable attributes and match them with the search string.
        
        :param str matchString: Search string to match with attributes
        :param list nodes: List of nodes to process the attributes from
        """
        # reset of search string is empty
        if not matchString:
            cmds.channelBox(CHANNELBOX, edit=True, fixedAttrList=[])
            return
    
        # split match string
        matches = []
        matchStrings = matchString.lower().split()
        
        # get matching attributes
        for node in nodes:
            attrs = cmds.listAttr(node, k=True, v=True)
            
            for attr in attrs:
                if (
                    not attr in matches and 
                    self.matchSearch(attr, matchStrings)
                ):
                    matches.append(attr)
               
        # append null if not matches are found ( cannot use empty list )
        if not matches:
            matches.append("null")

        # filter channel box
        cmds.channelBox(CHANNELBOX, edit=True, fixedAttrList=matches)
        
    # ------------------------------------------------------------------------ 
开发者ID:robertjoosten,项目名称:maya-channel-box-plus,代码行数:37,代码来源:ui.py

示例9: install

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import channelBox [as 别名]
def install(threshold=0.75):
    """
    Add the search interface and colouring functionality to Maya's main
    channel box. If channelBoxPlus is already installed a RuntimeError
    exception will be thrown. A threshold can be set, this threshold
    determines when the attributes should change colour. the higher the
    threshold the more the 2 attributes will have to match up to stay the same
    colour.

    :param float threshold: Threshold for attribute colour change
    :raises RuntimeError: When the channel box plus is already installed.
    """
    global CHANNELBOX_PLUS

    # validate channel box plus
    if CHANNELBOX_PLUS:
        raise RuntimeError("Channel box plus is already installed!")

    # get channel box
    channelBox = getChannelBox()

    # get channel box layout
    parent = channelBox.parent()
    layout = parent.layout()
    layout.setSpacing(0)

    # initialize search widget
    CHANNELBOX_PLUS = SearchWidget(parent, threshold)

    # add search widget to layout
    if type(layout) == QLayout:
        item = layout.itemAt(0)
        widget = item.widget()

        layout.removeWidget(widget)
        layout.addWidget(CHANNELBOX_PLUS)
        layout.addWidget(widget)
    else:
        layout.insertWidget(0, CHANNELBOX_PLUS) 
开发者ID:robertjoosten,项目名称:maya-channel-box-plus,代码行数:41,代码来源:ui.py

示例10: main

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import channelBox [as 别名]
def main(selectedChannels=True, transformsOnly=False, excludeChannels=None):
    '''
    Resets selected channels in the channel box to default, or if nothing's
    selected, resets all keyable channels to default.
    '''
    gChannelBoxName = mm.eval('$temp=$gChannelBoxName')

    sel = mc.ls(sl=True)
    if not sel:
        return

    if excludeChannels and not isinstance(excludeChannels, (list, tuple)):
        excludeChannels = [excludeChannels]

    chans = None
    if selectedChannels:
        chans = mc.channelBox(gChannelBoxName, query=True, sma=True)

    testList = ['translateX','translateY','translateZ','rotateX','rotateY','rotateZ','scaleX','scaleY','scaleZ',
                'tx','ty','yz','rx','ry','rz','sx','sy','sz']
    for obj in sel:
        attrs = chans
        if not chans:
            attrs = mc.listAttr(obj, keyable=True, unlocked=True)
            if excludeChannels and attrs:
                attrs = [x for x in attrs if x not in excludeChannels]
        if transformsOnly:
            attrs = [x for x in attrs if x in testList]
        if attrs:
            for attr in attrs:
                try:
                    default = mc.attributeQuery(attr, listDefault=True, node=obj)[0]
                    mc.setAttr(obj+'.'+attr, default)
                except StandardError:
                    pass

    utl.deselectChannels() 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:39,代码来源:ml_resetChannels.py

示例11: deselectChannels

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import channelBox [as 别名]
def deselectChannels():
    '''
    Deselect selected channels in the channelBox
    by clearing selection and then re-selecting
    '''

    if not getSelectedChannels():
        return
    sel = mc.ls(sl=True)
    mc.select(clear=True)
    mc.evalDeferred(partial(mc.select,sel)) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:13,代码来源:ml_utilities.py

示例12: on_add_btn_clicked

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import channelBox [as 别名]
def on_add_btn_clicked(self):
        
        selNodes = cmds.ls(sl=1, ap=1)
        if not selNodes:
            om.MGlobal.displayError("Please select some nodes and attributes.")
            return
        
        selAttrs = (cmds.channelBox("mainChannelBox", q=1, sma=1) or []) \
            + (cmds.channelBox("mainChannelBox", q=1, sha=1) or []) \
            + (cmds.channelBox("mainChannelBox", q=1, ssa=1) or []) \
            + (cmds.channelBox("mainChannelBox", q=1, soa=1) or [])
        
        if not selAttrs:
            selAttrs = cmds.listAttr(selNodes, v=1, k=1, sn=1)
            selAttrs = list(set(selAttrs))
            try:
                selAttrs.remove('v')
            except:
                pass
        
        self.table.clearSelection()
        
        for node in selNodes:
            for attr in selAttrs:
                name = "%s.%s" % (node, attr)
                minVal, maxVal = 0.0, 1.0
                hasMinVal, hasMaxVal = False, False
                
                if not cmds.objExists(name):
                    continue
                
                # Set minVal
                if cmds.attributeQuery(attr, node=node, minExists=1):
                    minVal = cmds.attributeQuery(attr, node=node, min=1)[0]
                    hasMinVal = True
                
                if cmds.attributeQuery(attr, node=node, softMinExists=1):
                    minVal = cmds.attributeQuery(attr, node=node, smn=1)[0]
                    hasMinVal = True
                
                # Set maxVal    
                if cmds.attributeQuery(attr, node=node, maxExists=1):
                    maxVal = cmds.attributeQuery(attr, node=node, max=1)[0]
                    hasMaxVal = True
                
                if cmds.attributeQuery(attr, node=node, softMaxExists=1):
                    maxVal = cmds.attributeQuery(attr, node=node, smx=1)[0]
                    hasMaxVal = True
                
                currVal = cmds.getAttr(name)
                if hasMinVal: minVal = minVal - currVal
                if hasMaxVal: maxVal = maxVal - currVal
                    
                self.appendRow()
                self.setRow(self.numRow()-1, [name, minVal, maxVal])
    
    #---------------------------------------------------------------------- 
开发者ID:WebberHuang,项目名称:DeformationLearningSolver,代码行数:59,代码来源:customAttributeEditor.py


注:本文中的maya.cmds.channelBox方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。