Python maya.cmds 模块,channelBox() 实例源码

我们从Python开源项目中,提取了以下44个代码示例,用于说明如何使用maya.cmds.channelBox()

项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def getObj(*args):
    #get selection and put it in the widgets["objTFG"]
    clearList()
    sel = cmds.ls(sl=True, type="transform")
    if (sel and (len(sel)==1)):
        cmds.textFieldGrp(widgets["objTFG"], e=True, tx=sel[0])
    else:
        cmds.warning("you must select one object with the \"follow\" attribute")

    #------------maybe add attr onto end of obj text, then you don't have to get it later if you needed to ???

    #now create a button for each value in the "follow" attr
    #channels = cmds.channelBox ('mainChannelBox', query=True, selectedMainAttributes=True)
    enumValueStr = cmds.attributeQuery("follow", node=sel[0], listEnum=True)[0]
    values = enumValueStr.split(":")

    for i in range(0,len(values)):
        #pick a random color?
        r = random.uniform(0.5,1)
        g = random.uniform(0.5,1)
        b = random.uniform(0.5,1)
        color = (r, g, b)

        #here create the button
        cmds.button(l=values[i], w=125, p=widgets["bottomRCLO"], bgc=color, h=50, c=partial(switchMatchSpace, i))
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def getAttr(*args):
    """grabs the selected channel from the selected obj and puts the enum values into the list"""
    #--------here could require a channel of a specific name, then you could do it automagically (check for "follow", "spaces", "space", "ss", etc)
    obj = cmds.textFieldGrp(widgets["objTFG"], q=True, tx=True)
    cmds.select(obj, r=True)
    channels = cmds.channelBox ('mainChannelBox', query=True, selectedMainAttributes=True)
    print channels
    if (channels and (len(channels)==1)):
        if (cmds.attributeQuery(channels[0], node=obj, enum=True)):
            enumValue = cmds.attributeQuery(channels[0], node=obj, listEnum=True)
            values = enumValue[0].split(":")
            for value in values:
                cmds.textScrollList(widgets["spacesTSL"], e=True, append=value)
                #----------create a button for each one???
                #----------or have them be double clicked???
    else:
        cmds.warning("select only the enum space switch channel")
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_expression(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("expressionEditor \"EE\" " + main_obj_list[0] + " " + main_attr_list[0] + ";")

        elif shape_obj_list and shape_attr_list:
            mel.eval("expressionEditor \"EE\" " + shape_obj_list[0] + " " + shape_attr_list[0] + ";")

        elif history_obj_list and history_attr_list:
            mel.eval("expressionEditor \"EE\" " + history_obj_list[0] + " " + history_attr_list[0] + ";")

        elif output_obj_list and output_attr_list:
            mel.eval("expressionEditor \"EE\" " + output_obj_list[0] + " " + output_attr_list[0] + ";")
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_setSpeed(box, menuItem, key, *args):
    # Sets the incremental size for attributes when modifying with middle mouse,
    #  eg 'medium' appends +1/-1, 'fast' is +10/-10
    with sysCmd.Undo(0):
        state = 1 if key == "speedSlow" else 2 if key == "speedMedium" else 3

        if state == 1:
            cmds.channelBox(box.channelbox, e=1, speed=0.1)
        elif state == 2:
            cmds.channelBox(box.channelbox, e=1, speed=1)
        else:
            cmds.channelBox(box.channelbox, e=1, speed=10)

        box.saved_states["speedState"][0] = state
        if box.saved_states["showIcons"][0]:
            channelbox_command_Symbol_update(box, "speedState")

        sysCmd.channelbox_save_state(box)
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_setManip(box, menuItem, key, *args):
    # Set manipulator display/update type based on selected attr in channel box
    with sysCmd.Undo(0):
        state = 1 if key == "noManips" else 2 if key == "invisibleManips" else 3

        if state == 1:
            cmds.channelBox(box.channelbox, e=1, useManips="none")
        elif state == 2:
            cmds.channelBox(box.channelbox, e=1, useManips="invisible")
        else:
            cmds.channelBox(box.channelbox, e=1, useManips="standard")

        box.saved_states["manipsState"][0] = state
        if box.saved_states["showIcons"][0]:
            channelbox_command_Symbol_update(box, "manipsState")

        sysCmd.channelbox_save_state(box)
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_precision(box, menuItem, key, *args):
    # floating point value displayed in channel box, eg. value of 5 will
    #  display 5 decimal places
    with sysCmd.Undo(0):
        old_precision = box.saved_states[key][0]
        new_precision = mel.eval("precisionPrompt (\"\", " + str(old_precision) + ", 15);")

        if new_precision > 0:  # Change widths of the fields depending on the precision
            if new_precision <= 3:
                new_width = 65
            elif new_precision <= 6:
                new_width = 95
            elif new_precision <= 9:
                new_width = 115
            elif new_precision <= 12:
                new_width = 130
            else:
                new_width = 155

            cmds.channelBox(box.channelbox, e=1, pre=new_precision, fieldWidth=new_width)
            box.saved_states[key][0] = new_precision
            box.saved_states["fieldWidth"][0] = new_width

        sysCmd.channelbox_save_state(box)
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelBox_SelectedPlugs(box):
    result = []

    def loop(which, _result):
        obj_list = cmds.channelBox(box.channelbox, q=1, mainObjectList=which[0], shapeObjectList=which[1],
                                   historyObjectList=which[2], outputObjectList=which[3])
        attr_list = cmds.channelBox(box.channelbox, q=1, selectedMainAttributes=which[0],
                                    selectedShapeAttributes=which[1], selectedHistoryAttributes=which[2],
                                    selectedOutputAttributes=which[3])

        if obj_list and attr_list:
            for obj in obj_list:
                for attr in attr_list:
                    _result.append(obj + "." + attr)

        return _result

    result = loop([1, 0, 0, 0], result)
    result = loop([0, 1, 0, 0], result)
    result = loop([0, 0, 1, 0], result)
    result = loop([0, 0, 0, 1], result)

    return result
    # -----------------------------------------
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
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
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
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)
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
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])
项目:zoocore    作者:dsparrow27    | 项目源码 | 文件源码
def setChannelBoxAtTop(channelBox, value):
    """
    :param channelBox: mainChannelBox
    :type channelBox: str
    :param value:
    :type value: bool
    :example::
        setChannelBoxAtTop("mainChannelBox",True)
    """
    cmds.channelBox(channelBox, edit=True, containerAtTop=value)
项目:zoocore    作者:dsparrow27    | 项目源码 | 文件源码
def setChannelShowType(channelBox, value):
    """
    :param channelBox: mainChannelBox
    :type channelBox: str
    :param value:
    :type value: str
    :example::
        setChannelShowType("mainChannelBox", "all")
    """
    cmds.optionVar(stringValue=("cbShowType", value))
    cmds.channelBox(channelBox, edit=True, update=True)
项目:config    作者:mindbender-studio    | 项目源码 | 文件源码
def read_selected_channels(*args):
    """Return a list of selected channels in the Channel Box"""
    channelbox = mel.eval("global string $gChannelBoxName; "
                          "$temp=$gChannelBoxName;")
    return cmds.channelBox(channelbox,
                           query=True,
                           selectedMainAttributes=True) or []
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def getChannels(*args):
    cBox = mel.eval('$temp=$gChannelBoxName')
    cAttrs = cmds.channelBox(cBox, q=True, selectedMainAttributes=True, ssa=True, sha=True, soa=True)
    return cAttrs
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def transfer_attrs(*args):
    """
    transfers attrs and connections from second obj to first object selected 
    """
    tgt, src = get_source_and_targets()
    if not tgt or len(src) > 1:
        cmds.warning("Select only one target then one source obj to transfer the attributes and connections!")
        return ()

    attrs = cmds.channelBox('mainChannelBox', q=True, selectedMainAttributes=True)
    if not attrs:
        cmds.warning("You have to select at least one attr on last object selected to transfer!")
        return ()
    for attr in attrs:
        attrType, hasMin, attrMin, hasMax, attrMax, value, inConnection, outConnection, locked = get_channel_attributes(
            src[0], attr)
        if not attrType == "enum":
            # create attribute
            if not cmds.attributeQuery(attr, node=tgt, exists=True):
                if hasMin and not hasMax:
                    cmds.addAttr(tgt, ln=attr, at=attrType, min=attrMin[0], dv=value, k=True)
                elif hasMax and not hasMin:
                    cmds.addAttr(tgt, ln=attr, at=attrType, max=attrMax[0], dv=value, k=True)
                elif hasMin and hasMax:
                    cmds.addAttr(tgt, ln=attr, at=attrType, min=attrMin[0], max=attrMax[0], dv=value, k=True)
                else:
                    cmds.addAttr(tgt, ln=attr, at=attrType, dv=value, k=True)
            else:
                cmds.warning("The attribute: {0} already exists. Skipping creation!".format(attr))
            # lock
            if locked:
                cmds.setAttr("{0}.{1}".format(tgt, attr), l=True)
        else:
            cmds.warning("I don't do enums at the moment!")

        # connect tgt attr to connection, forced
        if inConnection:
            cmds.connectAttr(inConnection[0], "{0}.{1}".format(tgt, attr))
        if outConnection:
            for conn in outConnection:
                cmds.connectAttr("{0}.{1}".format(tgt, attr), conn, force=True)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def get_selected_channel(tfbg, *args):
    """
    gets the selected channel of the selected objects
    tfbg = the key of the widget for the ui (from widgets dict). string
    """

    obj = ""
    channel = ""

    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)
        cmds.textFieldButtonGrp(widgets[tfbg], e=True, tx=full)
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_menu_selected_channels(box):
    obj_list = cmds.channelBox(box.channelbox, q=1, mainObjectList=1)
    attr_list = cmds.channelBox(box.channelbox, q=1, selectedMainAttributes=1)

    if obj_list and attr_list and len(obj_list) > 0 and len(attr_list) > 0:
        return 1

    obj_list = cmds.channelBox(box.channelbox, q=1, shapeObjectList=1)
    attr_list = cmds.channelBox(box.channelbox, q=1, selectedShapeAttributes=1)

    if obj_list and attr_list and len(obj_list) > 0 and len(attr_list) > 0:
        return 1

    obj_list = cmds.channelBox(box.channelbox, q=1, historyObjectList=1)
    attr_list = cmds.channelBox(box.channelbox, q=1, selectedHistoryAttributes=1)

    if obj_list and attr_list and len(obj_list) > 0 and len(attr_list) > 0:
        return 1

    obj_list = cmds.channelBox(box.channelbox, q=1, outputObjectList=1)
    attr_list = cmds.channelBox(box.channelbox, q=1, selectedOutputAttributes=1)

    if obj_list and attr_list and len(obj_list) > 0 and len(attr_list) > 0:
        return 1

    return 0
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_keyItem(box, menuItem, key, *args):
    with sysCmd.Undo():
        cmds.channelBox(box.channelbox, e=1,
                        exe=("if( `getAttr -k \"#P.#A\"`||`getAttr -channelBox \"#P.#A\"` )setKeyframe \"#P.#A\";", 1))
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_keyAll(box, menuItem, key, *args):
    with sysCmd.Undo():
        cmds.channelBox(box.channelbox, e=1, exe=("if( `getAttr -k \"#P.#A\"` ) setKeyframe \"#P.#A\";", 0))
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_breakdown(box, menuItem, key, *args):
    with sysCmd.Undo():
        cmds.channelBox(box.channelbox, e=1, exe=("setKeyframe -breakdown true \"#P.#A\";", 1))
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_breakdownAll(box, menuItem, key, *args):
    with sysCmd.Undo():
        cmds.channelBox(box.channelbox, e=1, exe=("setKeyframe -breakdown true \"#P.#A\";", 0))
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_muteAll(box, menuItem, key, *args):
    with sysCmd.Undo():
        cmds.channelBox(box.channelbox, e=1, exe=("mute \"#P.#A\";", 0))
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_unmute(box, menuItem, key, *args):
    with sysCmd.Undo():
        cmds.channelBox(box.channelbox, e=1, exe=("mute -disable -force \"#P.#A\";", 1))
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_unmuteAll(box, menuItem, key, *args):
    with sysCmd.Undo():
        cmds.channelBox(box.channelbox, e=1, exe=("mute -disable -force \"#P.#A\";", 0))
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_syncGraph(box, menuItem, key, *args):
    with sysCmd.Undo(0):
        state = channelBox_Checkbox_Update(box, key, menuItem)
        if not state and box.menu_jobs[key] > 0:
            # if user disabled the option, and ScriptJob is running, kill the ScriptJob
            cmds.scriptJob(k=box.menu_jobs[key])
            box.menu_jobs[key] = -1

        if state:
            mel.eval("GraphEditor;")  # open graph editor
            cmds.channelBox(box.channelbox, e=1, exe=(channelbox_command_animCurve(box, menuItem, key), 0))
            if box.menu_jobs[key] < 0:  # if ScriptJob is not running, start it
                box.menu_jobs[key] = cmds.scriptJob(
                    event=("ChannelBoxLabelSelected", partial(channelbox_command_syncGraph_scriptJob, box)),
                    parent=box.channelbox)
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_cut(box, menuItem, key, *args):
    with sysCmd.Undo():
        cmd = ""
        okay = 0

        def loop(which, _cmd, _okay):
            obj_list = cmds.channelBox(box.channelbox, q=1, mainObjectList=which[0], shapeObjectList=which[1],
                                       historyObjectList=which[2], outputObjectList=which[3])
            attr_list = cmds.channelBox(box.channelbox, q=1, selectedMainAttributes=which[0],
                                        selectedShapeAttributes=which[1], selectedHistoryAttributes=which[2],
                                        selectedOutputAttributes=which[3])

            if obj_list and attr_list:
                _cmd += "cutKey -t \":\" -f \":"
                for channel in attr_list:
                    _cmd += "\" -at \"" + channel
                for obj in obj_list:
                    _cmd += "\" " + obj
                _cmd += ";"
                _okay = 1

            return _cmd, _okay

        cmd, okay = loop([1, 0, 0, 0], cmd, okay)
        cmd, okay = loop([0, 1, 0, 0], cmd, okay)
        cmd, okay = loop([0, 0, 1, 0], cmd, okay)
        cmd, okay = loop([0, 0, 0, 1], cmd, okay)

        if okay == 1:
            print cmd
            print "// Result: " + str(mel.eval(cmd)) + " //"
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_paste(box, menuItem, key, *args):
    with sysCmd.Undo():
        cmd = ""
        okay = 0
        current_time = cmds.currentTime(q=1)

        def loop(which, _cmd, _okay):
            obj_list = cmds.channelBox(box.channelbox, q=1, mainObjectList=which[0], shapeObjectList=which[1],
                                      historyObjectList=which[2], outputObjectList=which[3])
            attr_list = cmds.channelBox(box.channelbox, q=1, selectedMainAttributes=which[0],
                                       selectedShapeAttributes=which[1], selectedHistoryAttributes=which[2],
                                       selectedOutputAttributes=which[3])

            if obj_list and attr_list:
                _cmd += "pasteKey -connect true -time " + str(current_time) + " "
                for channel in attr_list:
                    _cmd += "-at \"" + channel + "\" "
                for obj in obj_list:
                    _cmd += obj
                _cmd += ";"
                _okay = 1

            return _cmd, _okay

        cmd, okay = loop([1, 0, 0, 0], cmd, okay)
        cmd, okay = loop([0, 1, 0, 0], cmd, okay)
        cmd, okay = loop([0, 0, 1, 0], cmd, okay)
        cmd, okay = loop([0, 0, 0, 1], cmd, okay)

        if okay == 1:
            print cmd
            print "// Result: " + str(mel.eval(cmd)) + " //"
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_delete(box, menuItem, key, *args):
    with sysCmd.Undo():
        cmd = ""
        okay = 0

        def loop(which, _cmd, _okay):
            obj_list = cmds.channelBox(box.channelbox, q=1, mainObjectList=which[0], shapeObjectList=which[1],
                                       historyObjectList=which[2], outputObjectList=which[3])
            attr_list = cmds.channelBox(box.channelbox, q=1, selectedMainAttributes=which[0],
                                        selectedShapeAttributes=which[1], selectedHistoryAttributes=which[2],
                                        selectedOutputAttributes=which[3])

            if obj_list and attr_list:
                _cmd += "cutKey -cl -t \":\" -f \":"
                for channel in attr_list:
                    _cmd += "\" -at \"" + channel
                for obj in obj_list:
                    _cmd += "\" " + obj
                _cmd += ";"
                _okay = 1

            return _cmd, _okay

        cmd, okay = loop([1, 0, 0, 0], cmd, okay)
        cmd, okay = loop([0, 1, 0, 0], cmd, okay)
        cmd, okay = loop([0, 0, 1, 0], cmd, okay)
        cmd, okay = loop([0, 0, 0, 1], cmd, okay)

        if okay == 1:
            print cmd
            print "// Result: " + str(mel.eval(cmd)) + " //"


# --
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_unkeyable(box, menuItem, key, *args):
    cmds.channelBox(box.channelbox, e=1, exe=("setAttr -keyable false -channelBox false \"#P.#A\";", 1))
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_lockUnkeyable(box, menuItem, key, *args):
    cmds.channelBox(box.channelbox, e=1, exe=("setAttr -lock true -keyable false -channelBox false \"#P.#A\";", 1))
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_unkeyableDisplayed(box, menuItem, key, *args):
    cmds.channelBox(box.channelbox, e=1, exe=("setAttr -keyable false -channelBox true \"#P.#A\";", 1))
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
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) + ";")
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
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")
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
def channelbox_command_deleteAttributes(box, menuItem, key, *args):
    cmds.channelBox(box.channelbox, e=1, exe=("catch (`deleteAttr -attribute \"#A\" \"#P\"`);", 1))


# --
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
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)
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
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)
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
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)
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
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)
项目:ModularChannelBox    作者:Vaei    | 项目源码 | 文件源码
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_tools    作者:morganloomis    | 项目源码 | 文件源码
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_tools    作者:morganloomis    | 项目源码 | 文件源码
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()
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
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)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
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)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
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)