Ejemplo n.º 1
0
def jnt_at_mid_vertex_orient(**kwargs):
    sel = pm.ls(orderedSelection=True, flatten=True)
    if not sel:
        pm.displayInfo("Please select vertex")
        return None
    obj_pos_map = {}
    for comp in sel:
        if not isinstance(comp, pm.MeshVertex):
            pm.displayInfo("Please select only vertex")
            return None
    mid_pos = 0
    for comp in sel:
        comp.node()
        transform_node = pm.listTransforms(comp.node())[0]
        if transform_node not in obj_pos_map.keys():
            vrts = CustomScripts.get_vrts(sel_obj=[transform_node])[0]
            pos = CustomScripts.midPos(selected_items=vrts)
            obj_pos_map[transform_node] = pos
            mid_pos = pos
        else:
            mid_pos = obj_pos_map[transform_node]
        comp_pos = pm.pointPosition(comp, world=True)
        pm.select(clear=True)
        jnt1 = pm.joint(position=mid_pos)
        jnt2 = pm.joint(position=comp_pos)
        pm.joint(jnt1,
                 edit=True,
                 orientJoint='xyz',
                 secondaryAxisOrient='yup',
                 zeroScaleOrient=True)
        pm.select([jnt1, jnt2])
        CustomScripts.CopyJntOri()
    return None
Ejemplo n.º 2
0
def jnt_at_mid_vertex_orient(**kwargs):
    sel = pm.ls(orderedSelection=True, flatten=True)
    if not sel:
        pm.displayInfo("Please select vertex")
        return None
    obj_pos_map = {}
    for comp in sel:
        if not isinstance(comp, pm.MeshVertex):
            pm.displayInfo("Please select only vertex")
            return None
    mid_pos = 0
    for comp in sel:
        #vertex_position = pm.pointPosition(comp, world=True)
        #component_pos.append(vertex_position)
        shape_node = comp.node()
        transform_node = pm.listTransforms(comp.node())[0]
        if transform_node not in obj_pos_map.keys():
            vrts = CustomScripts.get_vrts(sel_obj=[transform_node])[0]
            print vrts
            pos = CustomScripts.midPos(selected_items=vrts)
            obj_pos_map[transform_node] = pos
            mid_pos = pos
        else:
            mid_pos = obj_pos_map[transform_node]
        print obj_pos_map
        comp_pos = pm.pointPosition(comp, world=True)
        pm.select(clear=True)
        jnt1 = pm.joint(position=mid_pos)
        jnt2 = pm.joint(position=comp_pos)
        pm.joint(jnt1,
                 edit=True,
                 orientJoint='xyz',
                 secondaryAxisOrient='yup',
                 zeroScaleOrient=True)
        pm.select([jnt1, jnt2])
        CustomScripts.CopyJntOri()

        #obj_list[comp] = transform_node
        #if transform_node not in obj_list:
        #    obj_list.append(transform_node)

    #vrts = CustomScripts.get_vrts(sel_obj = obj_list)
    #pos = []
    #for vrt in vrts:
    #    pos.append(CustomScripts.midPos(selected_items = vrt))

    #for p in component_pos:
    #    pm.select(clear=True)
    #    jnt1 = pm.joint(position=p)
    #    jnt2 = pm.joint(position = component_pos[pos.index(p)])
    #    pm.joint(jnt1, edit=True, orientJoint='xyz',
    #                 secondaryAxisOrient='yup', zeroScaleOrient=True)
    #    pm.select(clear=True)
    #    pm.select([jnt1, jnt2])
    #    CustomScripts.CopyJntOri()
    #    pm.select(clear=True)
    return None