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 __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_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 __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)