python类channelBox()的实例源码

jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def channelbox_command_unkeyableDisplayed(box, menuItem, key, *args):
    cmds.channelBox(box.channelbox, e=1, exe=("setAttr -keyable false -channelBox true \"#P.#A\";", 1))
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def channelbox_command_driven(box, menuItem, key, *args):
    with sysCmd.Undo(0):
        main_obj_list = cmds.channelBox(box.channelbox, q=1, mainObjectList=1)
        main_attr_list = cmds.channelBox(box.channelbox, q=1, selectedMainAttributes=1)

        shape_obj_list = cmds.channelBox(box.channelbox, q=1, shapeObjectList=1)
        shape_attr_list = cmds.channelBox(box.channelbox, q=1, selectedShapeAttributes=1)

        history_obj_list = cmds.channelBox(box.channelbox, q=1, historyObjectList=1)
        history_attr_list = cmds.channelBox(box.channelbox, q=1, selectedHistoryAttributes=1)

        output_obj_list = cmds.channelBox(box.channelbox, q=1, outputObjectList=1)
        output_attr_list = cmds.channelBox(box.channelbox, q=1, selectedOutputAttributes=1)

        if main_obj_list and main_attr_list:
            mel.eval("setDrivenKeyWindow " + "\"\"" + " " + channelBox_MelArray_Conversion(main_attr_list))

        elif shape_obj_list and shape_attr_list:
            mel.eval(
                "setDrivenKeyWindow " + shape_obj_list[0] + " " + channelBox_MelArray_Conversion(shape_attr_list) + ";")

        elif history_obj_list and history_attr_list:
            mel.eval(
                "setDrivenKeyWindow " + history_obj_list[0] + " " + channelBox_MelArray_Conversion(history_attr_list) + ";")

        elif output_obj_list and output_attr_list:
            mel.eval(
                "setDrivenKeyWindow " + output_obj_list[0] + " " + channelBox_MelArray_Conversion(output_attr_list) + ";")
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def channelbox_command_attributeEditor(box, menuItem, key, *args):
    with sysCmd.Undo(0):
        cmds.select(cmds.channelBox(box.channelbox, q=1, historyObjectList=1),
                    cmds.channelBox(box.channelbox, q=1, outputObjectList=1), add=1)
        mel.eval("openAEWindow")
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def channelbox_command_deleteAttributes(box, menuItem, key, *args):
    cmds.channelBox(box.channelbox, e=1, exe=("catch (`deleteAttr -attribute \"#A\" \"#P\"`);", 1))


# --
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def channelbox_command_selectNode(box, menuItem, key, *args):
    cmds.select(cmds.channelBox(box.channelbox, q=1, historyObjectList=1),
                cmds.channelBox(box.channelbox, q=1, outputObjectList=1), r=1)
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def channelbox_command_setHyperbolic(box, menuItem, key, *args):
    # Sets whether increments interpolate linearly or using a curve
    with sysCmd.Undo(0):
        state = channelBox_Checkbox_Update(box, key, menuItem)
        cmds.channelBox(box.channelbox, e=1, hyperbolic=state)
        box.saved_states["hyperbolic"][0] = state
        if box.saved_states["showIcons"][0]:
            channelbox_command_Symbol_update(box, "hyperbolic")

        sysCmd.channelbox_save_state(box)
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def channelbox_command_setNamespace(box, menuItem, key, *args):
    # Sets whether to display namespaces in the editor
    with sysCmd.Undo(0):
        state = channelBox_Checkbox_Update(box, key, menuItem)
        cmds.channelBox(box.channelbox, e=1, showNamespace=state)
        sysCmd.channelbox_save_state(box)
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def channelBox_filterAttrs(box):
    with sysCmd.Undo(0):
        names = []
        for key, value in box.filter_attrs.iteritems():
            if value:
                names.append(key)

        box.filter = cmds.itemFilterAttr(byNameString=names, negate=box.saved_states["invertShown"][0])
        cmds.channelBox(box.channelbox, e=1, attrFilter=box.filter, update=1)
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def channelbox_command_filter_filterShowAll(box, menuItem, key, *args):
    with sysCmd.Undo(0):
        channelbox_command_resetFilters(box)
        box.saved_states["invertShown"][0] = 0
        box.filter_attrs = {}

        cmds.channelBox(box.channelbox, e=1, attrFilter=0, update=1)

        channelBox_Filter_Items(box)
ml_utilities.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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))
ml_resetChannels.py 文件源码 项目:ml_tools 作者: morganloomis 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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:
                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()
zbw_rig.py 文件源码 项目:zTools 作者: zethwillie 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def get_selected_channels(full=True, long=True, *args):
    """
    for ONE object selected, return all selected channels from channel box
    :param full: (boolean) return the full name of the object.attr?, if false then returns only the attr names
    ":param long: (boolean) whether we should get the long name of the attr. False will give us "short" names
    :return: list of full obj.channel names selected, or (if not "full") just the channnel names
    """
    cBox = mel.eval('$temp=$gChannelBoxName')

    sel = cmds.ls(sl=True, l=True)
    if len(sel) != 1:
        cmds.warning("You have to select ONE node!")
        return(None)

    obj = sel[0]

    channelsRaw = cmds.channelBox(cBox, q=True, selectedMainAttributes=True, selectedShapeAttributes=True,
                               selectedHistoryAttributes=True,
                               selectedOutputAttributes=True)

    channels = []
    if channelsRaw:
        if long:
            for ch in channelsRaw:
                newC = cmds.attributeQuery(ch, node=obj, longName=True)
                channels.append(newC)
        else:
            for ch in channelsRaw:
                newC = cmds.attributeQuery(ch, node=obj, shortName=True)
                channels.append(newC)
    else: return(None)

    returnList = []
    if channels:
        if full:
            for c in channels:
                full = "{0}.{1}".format(obj, c)
                returnList.append(full)
        else:
            returnList = channels

        return(returnList)
    else:
        cmds.warning("zbw_rig.get_selected_channels: I didn't detect any channels selected!")
        return(None)
zbw_attributes.py 文件源码 项目:zTools 作者: zethwillie 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def getInput(*args):
    """ collects the input from the selected obj.channel"""

    obj = ""
    channel = ""
    conv = cmds.checkBox(widgets["conversionCB"], q=True, v=True)

    cBox = mel.eval('$temp=$gChannelBoxName')
    sel = cmds.ls(sl=True, l=True)

    if sel:
        if not len(sel) == 1:
            cmds.warning("You have to select ONE node!")
        else:
            obj = sel[0]
    else:
        cmds.warning("You have to select ONE node!")

    if sel:
        channels = cmds.channelBox(cBox, q=True, sma=True, ssa=True, sha=True, soa=True)

        if channels:
            if not len(channels) == 1:
                cmds.warning("You have to select ONE channel!")
            else:
                channel = channels[0]
        else:
            cmds.warning("You have to select ONE channel!")

    if obj and channel:
        full = "%s.%s" % (obj, channel)
        inAttr = cmds.listConnections(full, plugs=True, scn=conv, d=False, s=True)
        if inAttr:
            for each in inAttr:
                print "%s -----> %s" % (each, full)
        else:
            cmds.warning("No input connections on this attr!")
        inNodes = cmds.listConnections(full, scn=conv, d=False, s=True)
        if inNodes:
            cmds.select(cl=True)
            for node in inNodes:
                cmds.select(node, add=True)
zbw_attributes.py 文件源码 项目:zTools 作者: zethwillie 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def getOutput(*args):
    """ collects the outputs from the selected obj.channel"""

    obj = ""
    channel = ""
    conv = cmds.checkBox(widgets["conversionCB"], q=True, v=True)

    cBox = mel.eval('$temp=$gChannelBoxName')
    sel = cmds.ls(sl=True, l=True)

    if sel:
        if not len(sel) == 1:
            cmds.warning("You have to select ONE node!")
        else:
            obj = sel[0]
    else:
        cmds.warning("You have to select ONE node!")

    if sel:
        channels = cmds.channelBox(cBox, q=True, sma=True, ssa=True, sha=True, soa=True)

        if channels:
            if not len(channels) == 1:
                cmds.warning("You have to select ONE channel!")
            else:
                channel = channels[0]
        else:
            cmds.warning("You have to select ONE channel!")

    if obj and channel:
        full = "%s.%s" % (obj, channel)
        outAttr = cmds.listConnections(full, plugs=True, scn=conv, d=True, s=False)
        if outAttr:
            for each in outAttr:
                print "%s ----> %s" % (full, each)
        else:
            cmds.warning("No output connections on this attr!")
        outNodes = cmds.listConnections(full, scn=conv, d=True, s=False)
        if outNodes:
            cmds.select(cl=True)
            for node in outNodes:
                cmds.select(node, add=True)


问题


面经


文章

微信
公众号

扫码关注公众号