python类menuItem()的实例源码

jtChannelBox.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def channelbox_menu_object(box, menu, *args):
    cmds.menu(menu, e=1, deleteAllItems=1)

    sel = cmds.ls(os=1)

    if not sel:
        cmds.menuItem(l="Nothing selected", p=menu)
        return

    sel.reverse()
    first = 1

    for i in sel:
        m_item = cmds.menuItem(l=i, p=menu)
        m_item_box = cmds.menuItem(m_item, optionBox=1, p=menu)
        cmds.menuItem(m_item, e=1, c=sysCmd.rpartial(channelbox_command_objectmenu, box, menu, m_item, "select " + i))
        cmds.menuItem(m_item_box, e=1, c=sysCmd.rpartial(channelbox_command_objectmenu, box, menu, m_item_box, m_item,
                                                         "select " + i + " [  ]"))

        if first:
            cmds.menuItem(divider=1, p=menu)
            first = 0


# -----------------------------------------------------------------------------------#

# -----------------------------------------------------------------------------------#
# This is where the menu icons are setup
# You probably don't need to modify this, unless you have your own icons to add
# -----------------------------------------------------------------------------------#
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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))
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def channelbox_command_breakdown(box, menuItem, key, *args):
    with sysCmd.Undo():
        cmds.channelBox(box.channelbox, e=1, exe=("setKeyframe -breakdown true \"#P.#A\";", 1))
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 41 收藏 0 点赞 0 评论 0
def channelbox_command_breakdownAll(box, menuItem, key, *args):
    with sysCmd.Undo():
        cmds.channelBox(box.channelbox, e=1, exe=("setKeyframe -breakdown true \"#P.#A\";", 0))
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def channelbox_command_mute(box, menuItem, key, *args):
    with sysCmd.Undo():
        cmds.channelBox(box.channelbox, e=1, exe=("mute \"#P.#A\";", 1))
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def channelbox_command_muteAll(box, menuItem, key, *args):
    with sysCmd.Undo():
        cmds.channelBox(box.channelbox, e=1, exe=("mute \"#P.#A\";", 0))
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def channelbox_command_unmuteAll(box, menuItem, key, *args):
    with sysCmd.Undo():
        cmds.channelBox(box.channelbox, e=1, exe=("mute -disable -force \"#P.#A\";", 0))
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
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)
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def channelbox_command_syncTimeline(box, menuItem, key, *args):
    with sysCmd.Undo(0):
        state = channelBox_Checkbox_Update(box, key, menuItem)
        playback_slider = mel.eval("$tmpVar=$gPlayBackSlider")  # gets timeslider name
        if state:
            cmds.timeControl(playback_slider, e=1, showKeys=box.channelbox)
            cmds.timeControl(playback_slider, e=1, showKeysCombined=1)
        else:
            cmds.timeControl(playback_slider, e=1, showKeysCombined=0)
            cmds.timeControl(playback_slider, e=1, showKeys="active")


# --
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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)) + " //"
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def channelbox_command_copy(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 += "copyKey -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)) + " //"
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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)) + " //"


# --
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def channelbox_command_duplicateAttrValues(box, menuItem, key, *args):
    mel.eval("copyAttrValues")
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 40 收藏 0 点赞 0 评论 0
def channelbox_command_freezeTranslate(box, menuItem, key, *args):
    with sysCmd.Undo():
        if cmds.ls(sl=1):
            cmds.makeIdentity(t=1, r=0, s=0, n=0, a=1)
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def channelbox_command_freezeRotate(box, menuItem, key, *args):
    with sysCmd.Undo():
        if cmds.ls(sl=1):
            cmds.makeIdentity(t=0, r=1, s=0, n=0, a=1)
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def channelbox_command_freezeScale(box, menuItem, key, *args):
    with sysCmd.Undo():
        if cmds.ls(sl=1):
            cmds.makeIdentity(t=0, r=0, s=1, n=0, a=1)
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def channelbox_command_freezeTranslateScale(box, menuItem, key, *args):
    with sysCmd.Undo():
        if cmds.ls(sl=1):
            cmds.makeIdentity(t=1, r=0, s=1, n=0, a=1)
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def channelbox_command_freezeRotateScale(box, menuItem, key, *args):
    with sysCmd.Undo():
        if cmds.ls(sl=1):
            cmds.makeIdentity(t=0, r=1, s=1, n=0, a=1)
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def channelbox_command_freezeJointOrient(box, menuItem, key, *args):
    with sysCmd.Undo():
        if cmds.ls(sl=1):
            cmds.makeIdentity(t=0, r=0, s=0, n=0, jo=1, a=1)
jtChannelBox_Commands_Default.py 文件源码 项目:ModularChannelBox 作者: Vaei 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def channelbox_command_freezeAll(box, menuItem, key, *args):
    with sysCmd.Undo():
        state = cmds.menuItem(menuItem, q=1, isOptionBox=1)

        if not state:
            if cmds.ls(sl=1):
                cmds.makeIdentity(t=1, r=1, s=1, n=0, a=1)
        else:
            channelbox_command_freezeUI()


问题


面经


文章

微信
公众号

扫码关注公众号