def accept(self):
     """sets the new space
     """
     if self.listWidget.currentRow() == self.listWidget.count() - 1:
         self.listWidget.setCurrentRow(
             anim_utils.getComboIndex_with_namespace(
                 self.namespace, self.ui_host, self.combo_attr))
         # model = self.namespace + ":" + self.ui_host
         # print self.ctl
         # print model
         anim_utils.ParentSpaceTransfer.showUI(self.listWidget,
                                               self.ui_host,
                                               stripNamespace(self.ui_host),
                                               self.combo_attr,
                                               self.ctl)
     else:
         anim_utils.changeSpace_with_namespace(self.namespace,
                                               self.ui_host,
                                               self.combo_attr,
                                               self.listWidget.currentRow(),
                                               self.ctl)
         space = self.listWidget.item(self.listWidget.currentRow()).text()
         self.self_widget.text.set_text(space)
     self.close()
     self.deleteLater()
Beispiel #2
0
def __range_switch_callback(*args):
    """ Wrapper function to call mGears range fk/ik switch function

    Args:
        list: callback from menuItem
    """

    # instance for the range switch util
    range_switch = IkFkTransfer()

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

    # gets root node for the given control
    root = cmds.ls(args[0], long=True)[0].split("|")[1]

    # ik_controls, fk_controls = _get_controls(switch_control, blend_attr)
    # search criteria to find all the components sharing the blend
    criteria = blend_attr.replace("_blend", "") + "_id*_ctl"
    component_ctl = cmds.listAttr(switch_control, ud=True, string=criteria)
    if component_ctl:

        ik_controls, fk_controls = _get_controls(switch_control, blend_attr,
                                                 component_ctl[0])

        # calls the ui
        range_switch.showUI(model=root,
                            ikfk_attr=blend_attr,
                            uihost=stripNamespace(switch_control),
                            fks=fk_controls,
                            ik=ik_controls["ik_control"],
                            upv=ik_controls["pole_vector"],
                            ikRot=ik_controls["ik_rot"])
Beispiel #3
0
def __range_switch_callback(*args):
    """ Wrapper function to call mGears range fk/ik switch function

    Args:
        list: callback from menuItem
    """

    # instance for the range switch util
    range_switch = IkFkTransfer()

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

    # the gets root node for the given control
    # this assumes the rig is root is a root node.
    # But it's common practice to reference rigs into the scene
    # and use the reference group function to group incoming scene data.
    # Instead swap to _find_rig_root that will
    # do the same thing but account for potential parent groups.
    # root = cmds.ls(args[0], long=True)[0].split("|")[1]

    root = _find_rig_root(args[0])

    # ik_controls, fk_controls = _get_controls(switch_control, blend_attr)
    # 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)
    if component_ctl:
        ik_list = []
        ikRot_list = []
        fk_list = []
        upv_list = []

        for com_list in component_ctl:
            # set the initial val for the blend attr in each iteration
            ik_controls, fk_controls = get_ik_fk_controls_by_role(
                switch_control, com_list)
            ik_list.append(ik_controls["ik_control"])
            if ik_controls["ik_rot"]:
                ikRot_list.append(ik_controls["ik_rot"])
            upv_list.append(ik_controls["pole_vector"])
            fk_list = fk_list + fk_controls

        # calls the ui
        range_switch.showUI(model=root,
                            ikfk_attr=blend_attr,
                            uihost=stripNamespace(switch_control),
                            fks=fk_list,
                            ik=ik_list,
                            upv=upv_list,
                            ikRot=ikRot_list)
    def _get_node(name):
        # type: (str) -> pm.nodetypes.Transform
        name = anim_utils.stripNamespace(name)
        if namespace:
            node = anim_utils.getNode(":".join([namespace, name]))
        else:
            node = anim_utils.getNode(name)

        if not node:
            mgear.log("Can't find object : {0}".format(name), mgear.sev_error)

        return node
Beispiel #5
0
def __range_switch_callback(*args):
    """ Wrapper function to call mGears range fk/ik switch function

    Args:
        list: callback from menuItem
    """

    # instance for the range switch util
    range_switch = IkFkTransfer()

    # switch_control = args[0].split("|")[-1].split(":")[-1]
    switch_control = args[0].split("|")[-1]
    blend_attr = args[1]

    # gets root node for the given control
    root = cmds.ls(args[0], long=True)[0].split("|")[1]

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

    # calls the ui
    range_switch.showUI(model=root,
                        ikfk_attr=blend_attr,
                        uihost=stripNamespace(switch_control),
                        fks=fk_controls,
                        ik=ik_controls["ik_control"],
                        upv=ik_controls["pole_vector"],
                        ikRot=ik_controls["ik_rot"])
def gatherMirrorData(nameSpace, node, flip):
    """Get the data to mirror

    Args:
        nameSpace (str): Namespace
        node (PyNode): No
        flip (TYPE): flip option

    Returns:
        [dict[str]: The mirror data
    """
    if anim_utils.isSideElement(node.name()):

        nameParts = anim_utils.stripNamespace(node.name()).split("|")[-1]
        nameParts = anim_utils.swapSideLabel(nameParts)
        nameTarget = ":".join([nameSpace, nameParts])

        oTarget = anim_utils.getNode(nameTarget)

        return calculateMirrorData(node, oTarget, flip=flip)

    else:
        return calculateMirrorData(node, node, flip=False)