コード例 #1
0
ファイル: dagmenu.py プロジェクト: jeanim/mrs_core
def __switch_fkik_callback(*args):
    """ Wrapper function to call mGears switch fk/ik snap function

    Args:
        list: callback from menuItem
    """

    switch_control = args[0].split("|")[-1]
    keyframe = args[1]
    blend_attr = args[2]

    # gets namespace
    namespace = getNamespace(switch_control)

    # first find controls from the ui host control
    ik_fk_controls = get_ik_fk_controls(switch_control, blend_attr)

    # organise ik controls
    ik_controls = {"ik_control": None, "pole_vector": None, "ik_rot": None}

    # removes namespace from controls and order them in something usable
    # by the ikFkMatch function

    # - IKS
    for x in ik_fk_controls["ik_controls"]:
        control_name = x.split(":")[-1]
        control_type = control_name.split("_")[-2]
        if control_type == "ik":
            ik_controls["ik_control"] = control_name
        elif control_type == "upv":
            ik_controls["pole_vector"] = control_name
        elif control_type == "ikRot":
            ik_controls["ik_rot"] = control_name

    # - FKS
    fk_controls = [x.split(":")[-1] for x in ik_fk_controls["fk_controls"]]
    fk_controls = sorted(fk_controls)

    # runs switch
    ikFkMatch_with_namespace(namespace=namespace,
                             ikfk_attr=blend_attr,
                             ui_host=switch_control,
                             fks=fk_controls,
                             ik=ik_controls["ik_control"],
                             upv=ik_controls["pole_vector"],
                             ik_rot=ik_controls["ik_rot"],
                             key=keyframe)
コード例 #2
0
def __switch_fkik_callback(*args):
    """ Wrapper function to call mGears switch fk/ik snap function

    Args:
        list: callback from menuItem
    """

    switch_control = args[0].split("|")[-1]
    keyframe = args[1]
    blend_attr = args[2]

    # gets namespace
    namespace = getNamespace(switch_control)

    # search criteria to find all the components sharing the blend
    criteria = blend_attr.replace("_blend", "") + "_id*_ctl_cnx"
    component_ctl = cmds.listAttr(switch_control,
                                  ud=True,
                                  string=criteria)
    blend_fullname = "{}.{}".format(switch_control, blend_attr)
    for i, comp_ctl_list in enumerate(component_ctl):
        # we need to need to set the original blend value for each ik/fk match
        if i == 0:
            init_val = cmds.getAttr(blend_fullname)
        else:
            cmds.setAttr(blend_fullname, init_val)

        ik_controls, fk_controls = get_ik_fk_controls_by_role(switch_control,
                                                              comp_ctl_list)

        # runs switch
        ikFkMatch_with_namespace(namespace=namespace,
                                 ikfk_attr=blend_attr,
                                 ui_host=switch_control,
                                 fks=fk_controls,
                                 ik=ik_controls["ik_control"],
                                 upv=ik_controls["pole_vector"],
                                 ik_rot=ik_controls["ik_rot"],
                                 key=keyframe,
                                 ik_controls=ik_controls)
コード例 #3
0
    def mousePressEvent(self, event):
        # type: (QtCore.QEvent) -> None

        mouse_button = event.button()

        model = syn_utils.getModel(self)
        ikfk_attr = str(self.property("ikfk_attr"))
        uiHost_name = str(self.property("uiHost_name"))

        if not self.numFkControllers:
            self.numFkControllers = self.searchNumberOfFkControllers()

        additional_fk = self.property("additional_fk")
        if additional_fk:
            fks = [additional_fk]
        else:
            fks = []

        for i in range(self.numFkControllers):
            label = "fk{0}".format(str(i))
            prop = str(self.property(label))
            fks.append(prop)

        ik = str(self.property("ik"))
        upv = str(self.property("upv"))
        ikRot = str(self.property("ikRot"))
        if ikRot == "None":
            ikRot = None

        if mouse_button == QtCore.Qt.RightButton:
            IkFkTransfer.showUI(model, ikfk_attr, uiHost_name, fks, ik, upv,
                                ikRot)
            return

        else:
            current_namespace = anim_utils.getNamespace(model)
            ikFkMatch(current_namespace, ikfk_attr, uiHost_name, fks, ik, upv,
                      ikRot)
            return