示例#1
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)

    # 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)