Example #1
0
def ins_jnt(**kwargs):
    num = kwargs.get("num_jts", 1)
    sel = pm.ls(selection=True)
    chld = pm.listRelatives(sel[0], children=True)
    if not chld[0].type() == "joint":
        print "end joint reached"
        return None
    #position_lst = []
    pos1 = pm.xform(sel[0], query=True, worldSpace=True, translation=True)
    pos2 = pm.xform(chld, query=True, worldSpace=True, translation=True)
    len_vec1 = OpenMaya.MVector(pos1[0], pos1[1], pos1[2])
    len_vec2 = OpenMaya.MVector(pos2[0], pos2[1], pos2[2])
    len_vec = len_vec2 - len_vec1
    print len_vec.x, len_vec.y, len_vec.z
    part_vec = len_vec / (num + 1)
    pos_vec = len_vec1 + len_vec / (num + 1)
    cur_jnt = sel[0]
    for i in range(num):
        new_position = [pos_vec.x, pos_vec.y, pos_vec.z]
        #print new_position
        new_joint = pm.insertJoint(cur_jnt)
        pm.joint(new_joint, edit=True, component=True, position=new_position)
        #pm.xform(new_joint, translation=new_position)
        pos_vec += part_vec
        cur_jnt = new_joint
    return None
Example #2
0
def jnt_along_loop():
    import splitLoops
    #reload(splitLoops)
    loops = splitLoops.split_loop()
    if not loops:
        pm.displayInfo("please select only edge loops")
        return None
    else:
        verts = loops[1]
        loops = loops[0]
    #print loops
    #print verts
    pos = []
    for i in range(len(loops)):
        pos.append(CustomScripts.midPos(selected_items=verts[i]))

    print pos
    jnt_lst = []
    for p in pos:
        print p
        jnt = pm.joint(position=p)
        jnt_lst.append(jnt)
        if len(jnt_lst) > 1:
            pm.joint(jnt_lst[pos.index(p) - 1],
                     edit=True,
                     orientJoint='xyz',
                     secondaryAxisOrient='yup',
                     zeroScaleOrient=True)
    return None
    def autoOrientXKeepZ(self, obj ):
        assert isinstance(obj, pymel.core.nodetypes.Transform)
        
        unrepar = Unreparenter( obj )
        pm.makeIdentity( obj, apply=True, t=1, r=1, s=1, n=0, pn=1 )
        target = pm.createNode('joint')
        cons = [
            pm.pointConstraint( obj, target ),
            pm.orientConstraint( obj, target ),
            pm.scaleConstraint( obj, target )
        ]
        pm.delete( cons )
        
        
        unrepar.reparent()
        pm.joint( obj, edit=True,
            oj='xzy', secondaryAxisOrient='yup',
            zeroScaleOrient=True, children=False
        )
        unrepar.unparent( )
        pm.makeIdentity( obj, apply=True, t=1, r=1, s=1, n=0, pn=1 )
        
        
        self.rotateOnXToMatchZ(obj,target)

        pm.delete( target )
        
        pm.makeIdentity( obj, apply=True, t=1, r=1, s=1, n=0, pn=1 )
        unrepar.reparent(clean=True)
Example #4
0
def get_loop_from_edge():
    sel = pm.ls(orderedSelection=True)
    mid_pos = []
    pm.select(clear=True)
    for edg in sel:
        obj_sh_name = str(edg).split(".")[0]
        obj_name = pm.listRelatives(obj_sh_name, parent=True)
        edg_num = int((edg.split("[")[1]).replace("]", ""))
        pm.polySelect(obj_name, edgeLoopOrBorder=edg_num)
        edg_sel = pm.ls(selection=True)
        mid_pos.append(CustomScripts.midPos(selected_items=edg_sel))
        pm.select(clear=True)
    pm.select(clear=True)
    jnts = []
    for pos in mid_pos:
        cur_jnt = pm.joint(position=pos)
        jnts.append(cur_jnt)
        index = mid_pos.index(pos)
        if index > 0:
            pm.joint(jnts[index - 1],
                     edit=True,
                     orientJoint="xyz",
                     secondaryAxisOrient="yup",
                     children=True,
                     zeroScaleOrient=True)
    pm.select(clear=True)
    pm.select(jnts[-2], jnts[-1])
    CustomScripts.CopyJntOri()
    pm.select(clear=True)
    pm.select(jnts[-1])
    return None
Example #5
0
def insJnt():
    selected = pm.ls(selection=True)
    for index in range(len(selected) - 1):
        mid_pos = midPos(selected_items=[selected[index], selected[index + 1]])
        new_joint = pm.insertJoint(selected[index])
        pm.joint(new_joint, edit=True, component=True, position=mid_pos)
    return None
Example #6
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
Example #7
0
def dense_chain(**kwargs):
    import pymel.core.datatypes as dt
    joints = kwargs.get("joints", None)
    joints_inbetween = kwargs.get("joints_inbetween", 5)
    if not joints:
        joints = pm.ls(selection=True)
    joints.pop(-1)
    for jnt in joints:
        child = jnt.getChildren()
        pos = pm.xform(jnt, query=True, translation=True, worldSpace=True)
        vpos1 = dt.Vector(pos)
        pos = pm.xform(child[0], query=True, translation=True, worldSpace=True)
        vpos2 = dt.Vector(pos)
        vpos = vpos2 - vpos1
        div_vec = vpos / (joints_inbetween + 1)
        out_vec = vpos1
        cur_jnt = jnt
        for i in range(joints_inbetween):
            out_vec = (out_vec + div_vec)
            pos = [out_vec.x, out_vec.y, out_vec.z]
            new_jnt = pm.insertJoint(cur_jnt)
            pm.joint(new_jnt,
                     edit=True,
                     component=True,
                     position=pos,
                     name=str(i))
            cur_jnt = new_jnt
    return None
 def place_objects(self, **kwargs):
     interval = kwargs.get("skip", 0)
     if not self.loop:
         pm.displayError("no Loops received")
         return None
     if interval > len(self.loop):
         pm.displayError(
             "Skipping value larger than number of edges present")
         return self.FAIL
     jnt_lst = []
     index = 0
     max_len = len(self.loop)
     while index < max_len:
         pos = CustomScripts.midPos(selected_items=self.loop[index])
         jnt_lst.append(pm.joint(position=pos))
         if len(jnt_lst) > 1:
             pm.parent(jnt_lst[-1], jnt_lst[-2])
             pm.joint(jnt_lst[-2],
                      edit=True,
                      orientJoint='xyz',
                      secondaryAxisOrient='yup',
                      zeroScaleOrient=True)
         index += interval + 1
     pm.select(jnt_lst[-2], jnt_lst[-1])
     CustomScripts.CopyJntOri()
     return jnt_lst
Example #9
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
Example #10
0
def jnt_at_object_mid(**kwargs):
    sel = pm.ls(orderedSelection=True, flatten=True)
    for tran in sel:
        if not isinstance(tran, pm.Transform):
            pm.displayinfo("Please select only transform nodes")
            return None
    if not sel:
        pm.displayInfo("please select transform object")
    pos = []
    for obj in sel:
        pos.append(CustomScripts.midPos(selected_items=obj))
    pm.select(clear=True)
    for p in pos:
        pm.joint(position=p)
        pm.select(clear=True)
    return None
def createJoint(positionList):
    for pos in position_list:
        pm.select(clear=True)
        new_joint = pm.joint(position=pos)
        new_joint.radius.set(0.2)
        pm.select(clear=True)
    return None
Example #12
0
def joints_along_curve(**kwargs):
    number_of_joints = kwargs.get("number_of_joints", 2)
    bind_curve = kwargs.get("bind_curve_to_joint", False)
    curve = kwargs.get("curve", None)

    if not isinstance(curve, pm.PyNode):
        curve = pm.PyNode(bind_curve)
    crv_len = curve.length()
    parts = number_of_joints - 1
    div = float(crv_len) / float(parts)
    len_lst = [0]
    inc = 0
    for i in range(1, parts + 1):
        inc += div
        len_lst.append(inc)
    joint_lst = []
    for val in len_lst:
        pm.select(clear=True)
        param = curve.findParamFromLength(val)
        point = curve.getPointAtParam(param)
        jnt = pm.joint(position=point, radius=3)
        joint_lst.append(jnt)
    if bind_curve:
        pm.skinCluster(joint_lst, curve)
    return joint_lst
Example #13
0
 def create_joint(self, **kwargs):
     crv = kwargs.get("crv_node", "")
     if isinstance(crv, list):
         crv = pm.PyNode(crv[0])
     crv = pm.PyNode(crv)
     shp = crv.getShape()
     pm.select(clear=True)
     ctr = pm.joint()
     pm.parent(shp, ctr, relative=True, shape=True)
     pm.delete(crv)
     return ctr
    def at_selection(self, **kwargs):
        # get inputs
        setup_name = kwargs.get("name", None)
        path_name = kwargs.get("path", None)
        sample_obj = kwargs.get("sample", None)
        obj_lst = kwargs.get("selection_list", None)
        full_length = pm.arclen(path_name)
        paramVal = []
        uVal = []
        for obj in obj_lst:
            pos = pm.xform(obj, query=True, translation=True, worldSpace=True)
            param = self.getuParamVal(pnt=pos, crv=path_name)
            paramVal.append(param)
        crv_shp = pm.listRelatives(path_name, shapes=True)[0]
        arcLen = pm.arcLengthDimension(crv_shp + ".u[0]")
        for val in paramVal:
            pm.setAttr(str(arcLen) + ".uParamValue", val)
            len_at_pos = pm.getAttr(str(arcLen) + ".arcLength")
            uVal.append(len_at_pos / full_length)
        pm.delete(arcLen)
        path_anim_list = []
        if not self.get_use_selection():
            obj_lst = []
            if sample_obj:
                for i in uVal:
                    obj_lst.append(
                        pm.duplicate(sample_obj,
                                     name=setup_name + str(i + 1) + "_OBJECT"))
            else:
                for i in uVal:
                    pm.select(clear=True)
                    obj_lst.append(
                        pm.joint(name=setup_name + str(i + 1) + "_JNT"))

        index = 0
        for u in uVal:
            pm.select(clear=True)
            pathanim = pm.pathAnimation(obj_lst[index],
                                        curve=path_name,
                                        fractionMode=True,
                                        follow=True,
                                        followAxis="x",
                                        worldUpType="vector",
                                        worldUpVector=(0, 1, 0))
            index += 1
            path_anim_list.append(pathanim)
            pm.setAttr(str(pathanim) + ".uValue", u)
            pm.disconnectAttr(str(pathanim) + ".u")
        return (obj_lst, path_anim_list)
    def uniform_distribution(self, **kwargs):
        setup_name = kwargs.get("name", None)
        path_name = kwargs.get("path", None)
        sample_obj = kwargs.get("sample", None)
        divisions = kwargs.get("divisions", None)
        count = 0
        part = float(1) / float(divisions)
        init = 0
        obj_lst = []
        path_anim_list = []

        if not sample_obj:
            for i in range(divisions):
                pm.select(clear=True)
                obj_lst.append(pm.joint(name=setup_name + str(i + 1) + "_JNT"))

        else:
            for i in range(divisions):
                obj_lst.append(
                    pm.duplicate(sample_obj,
                                 name=setup_name + str(i + 1) + "_Object"))

        index = 0

        while count < divisions:
            pathanim = pm.pathAnimation(obj_lst[index],
                                        curve=path_name,
                                        fractionMode=True,
                                        follow=True,
                                        followAxis="x",
                                        worldUpType="vector",
                                        worldUpVector=(0, 1, 0))
            index += 1
            path_anim_list.append(pathanim)
            pm.setAttr(str(pathanim) + ".uValue", init)
            pm.disconnectAttr(str(pathanim) + ".u")
            init += part
            count += 1

        return (obj_lst, path_anim_list)
Example #16
0
def createTwistJointToSelectedChild():
    objs = pm.ls(selection=True)

    ## Make an empty list to store joints in
    newJoints = []

    for obj in objs:
        pm.select( clear=True )
        child = obj
        parentJnt = obj.getParent()
        jnt = pm.joint(position=[0,0,0])


        pc = pm.pointConstraint( [parentJnt, child] , jnt )
        oc = pm.orientConstraint( parentJnt, jnt )
        pm.delete( pc )
        pm.delete( oc )
        pm.parent( jnt, parentJnt )
        ## Put out new joint in the list!
        newJoints.append( jnt )
Example #17
0
import pymel.all as pm

objs = pm.ls(selection=True)

## Make an empty list to store joints in
newJoints = []

for obj in objs:
    pm.select(clear=True)
    child = obj
    parentJnt = obj.getParent()
    jnt = pm.joint(position=[0, 0, 0])

    pc = pm.pointConstraint([parentJnt, child], jnt)
    oc = pm.orientConstraint(parentJnt, jnt)
    pm.delete(pc)
    pm.delete(oc)
    pm.parent(jnt, parentJnt)
    ## Put out new joint in the list!
    newJoints.append(jnt)

pm.select(newJoints)
Example #18
0
def jntAtmid(**kwargs):
    sel_items = pm.ls(selection=True, flatten=True)
    mid_position = midPos(selected_items=sel_items)
    pm.select(clear=True)
    pm.joint(position=mid_position)
    return None
Example #19
0
 def set_rotation_limits(self, minX, maxX, minY, maxY, minZ, maxZ):
     pm.joint(self.mayaID, edit=True, limitX=(minX, maxX), limitY=(minY, maxY), limitZ=(minZ, maxZ))
Example #20
0
 def set_rotation_limit_z(self, minZ, maxZ):
     pm.joint(self.mayaID, edit=True, limitZ=(minZ, maxZ))
Example #21
0
 def set_rotation_limit_y(self, minY, maxY):
     pm.joint(self.mayaID, edit=True, limitY=(minY, maxY))
Example #22
0
 def set_rotation_limit_x(self, minX, maxX):
     pm.joint(self.mayaID, edit=True, limitX=(minX, maxX))
Example #23
0
def treadAtPoints(**kwargs):
    #get inputs
    tread_name = kwargs.get("tr_name", "Tread")
    crv = kwargs.get("path_crv", None)
    crv = str(pm.duplicate(crv, name=str(tread_name) + "PathCrv")[0])
    pm.xform(crv, centerPivots=True)
    #obtain curve length
    full_length = pm.arclen(crv)
    paramVal = []
    uVal = []
    # get param value on the curve at each position selected (locators)
    sel_obj = pm.ls(selection=True)
    for obj in sel_obj:
        pos = pm.xform(obj, query=True, translation=True, worldSpace=True)
        param = getuParamVal(pos, crv)
        paramVal.append(param)
    crv_shp = pm.listRelatives(crv, shapes=True)[0]
    # create arc length dimension tool
    arcLen = pm.arcLengthDimension(crv_shp + ".u[0]")
    # for each param value obtained set the arc length tool attribute and
    # store the length of curve at that param value
    # normalize the curve to obtain the motion path U value at each position
    for val in paramVal:
        pm.setAttr(str(arcLen) + ".uParamValue", val)
        len_at_pos = pm.getAttr(str(arcLen) + ".arcLength")
        uVal.append(len_at_pos / full_length)
    pm.delete(arcLen)
    mthPthLst = []
    jntLst = []
    # create joints, assign motion path and set U value obtained
    for u in uVal:
        pm.select(clear=True)
        jnt = pm.joint()
        jntLst.append(jnt)
        pathanim = pm.pathAnimation(jnt,
                                    curve=crv,
                                    fractionMode=True,
                                    follow=True,
                                    followAxis="x",
                                    worldUpType="vector",
                                    worldUpVector=(0, 1, 0))
        mthPthLst.append(pathanim)
        pm.setAttr(str(pathanim) + ".uValue", u)
        pm.disconnectAttr(str(pathanim) + ".u")
        # create up locator at mid point of all joints
    #loc_pos = midPos(selected_items = jntLst)
    #loc_pos = pm.xform(crv, query=True, translation=True, worldSpace=True)
    loc_pos = midPosVec(objects=jntLst)
    loc = pm.spaceLocator()
    pm.xform(loc, translation=loc_pos, worldSpace=True)
    for mtPth in mthPthLst:
        pm.pathAnimation(mtPth,
                         edit=True,
                         worldUpType="object",
                         worldUpObject=loc)
    # create control curve, add run and speed attributes
    control_crv = pm.circle(name=tread_name + "CTRL",
                            normalX=1,
                            normalY=0,
                            normalZ=0)
    pm.xform(control_crv, translation=loc_pos)
    pm.select(clear=True)
    pm.addAttr(control_crv,
               longName="run",
               attributeType="float",
               keyable=True)
    pm.addAttr(control_crv,
               longName="speed",
               attributeType="float",
               keyable=True,
               minValue=0.0,
               defaultValue=0.5)
    # group the tread setup
    pm.parent(crv, control_crv)
    pm.parent(loc, control_crv)
    pm.select(clear=True)
    gp = pm.group(name=tread_name + "GP")
    pm.select(clear=True)
    jnt_gp = pm.group(jntLst, name=tread_name + "JNTGP")
    pm.xform(gp, translation=loc_pos)
    pm.parent(control_crv, gp)
    pm.parent(jnt_gp, gp)
    createTreadExpression(mtnPth=mthPthLst,
                          runAttr=str(control_crv[0]) + ".run",
                          speedAttr=str(control_crv[0]) + ".speed",
                          exp_nm=tread_name)
    return None


#treadAtPoints(pathCrv = "nurbsCircle1", tr_name = "testTread")
import pymel.all as pm

objs = pm.ls(selection=True)

## Make an empty list to store joints in
newJoints = []

for obj in objs:
    pm.select( clear=True )
    child = obj
    parentJnt = obj.getParent()
    jnt = pm.joint(position=[0,0,0])


    pc = pm.pointConstraint( [parentJnt, child] , jnt )
    oc = pm.orientConstraint( parentJnt, jnt )
    pm.delete( pc )
    pm.delete( oc )
    pm.parent( jnt, parentJnt )
    ## Put out new joint in the list!
    newJoints.append( jnt )

pm.select( newJoints )
Example #25
0
def create_joint(*args):
    """This method creates Joints at user selected positions
    
    function call format : create_locator("String", Integer)
    
    User Inputs:
        args[0] : Object name
        args[1] : object Id to start with
    
    Returns : None
    """
    # If number of parameters mismatch, return with message
    if len(args) != 2:
        print "arguments mismatch"
        return None

    # Call to method to obtain list of selected position
    position_list = obtain_selection_position()

    # If user selected nothing, return with message display
    if not position_list:
        print 'please make selection'
        return None

    # clear all selections to create the root joint in current chain
    pm.select(clear=True)
    # Create empty list to store the joints being created
    joint_list = []

    # Obtain object name from args
    object_name = args[0]
    # Obtain the object ID from args as integer
    object_id = int(args[1])

    # Create joints at selected positions and increment
    # ID value to name the next joint in loop
    for index in range(len(position_list)):
        if object_id < 10:
            joint_name = object_name + "0" + str(object_id) + '_Joint'
        else:
            joint_name = object_name + str(object_id) + '_Joint'

        # First joint in chain is created at specified location
        if index < 1:
            created_joint = pm.joint(name=joint_name,
                                     position=position_list[index])
        # Create a child joint by selecting the previous joint as parent and
        # The previous joint orientation is edited so its X Axis points child
        else:
            pm.select(joint_list[index - 1])
            created_joint = pm.joint(name=joint_name,
                                     position=position_list[index])
            pm.joint(joint_list[index - 1],
                     edit=True,
                     orientJoint='xyz',
                     secondaryAxisOrient='yup',
                     zeroScaleOrient=True)

        # New joint created is appended to joint_list
        joint_list.append(created_joint)

        # Object id value is incremented by one for next joint name
        object_id = object_id + 1
    return None
def createTread(**kwargs):
    # get inputs
    divisions = kwargs.get("no_of_joints", 0)
    tread_name = kwargs.get("tr_name", "Tread")
    path_crv = kwargs.get("path_crv", None)
    # duplicate the existing curve to use for tread creation
    path_crv = str(pm.duplicate(path_crv, name=str(tread_name) + "PathCrv")[0])
    pm.xform(path_crv, centerPivots=True)
    count = 0
    part = float(1) / float(divisions)
    init = 0
    path_anim_list = []
    jnt_lst = []
    # create joints and place them on curve using motion path at equal distance
    while count < divisions:
        pm.select(clear=True)
        jnt = pm.joint()
        jnt_lst.append(jnt)
        pathanim = pm.pathAnimation(jnt,
                                    curve=path_crv,
                                    fractionMode=True,
                                    follow=True,
                                    followAxis="x",
                                    worldUpType="vector",
                                    worldUpVector=(0, 1, 0))
        path_anim_list.append(pathanim)
        pm.setAttr(str(pathanim) + ".uValue", init)
        pm.disconnectAttr(str(pathanim) + ".u")
        init += part
        count += 1
        # obtain the midpoint of all joints to create an up locator and position it at midpoint
    #loc_pos = midPos(selected_items = jnt_lst)
    #loc_pos = pm.xform(path_crv, query=True, translation=True, worldSpace=True)
    loc_pos = midPosVec(objects=jnt_lst)
    loc = pm.spaceLocator(name=tread_name + "_up_loc")
    pm.xform(loc, translation=loc_pos)
    # create a nurb circle to act as parent controller
    control_crv = pm.circle(name=tread_name + "CTRL",
                            normalX=1,
                            normalY=0,
                            normalZ=0)
    pm.xform(control_crv, translation=loc_pos)
    pm.select(clear=True)
    # add unr and speed attributes on parent nurb curve
    pm.addAttr(control_crv,
               longName="run",
               attributeType="float",
               keyable=True)
    pm.addAttr(control_crv,
               longName="speed",
               attributeType="float",
               keyable=True,
               minValue=0.0,
               defaultValue=0.5)
    #edit the existing motion path to assign up locator
    for mtPth in path_anim_list:
        pm.pathAnimation(mtPth,
                         edit=True,
                         worldUpType="object",
                         worldUpObject=loc)
    #parent the setup under the parent nurb curve
    pm.parent(path_crv, control_crv)
    pm.parent(loc, control_crv)
    pm.select(clear=True)
    gp = pm.group(name=tread_name + "GP")
    pm.select(clear=True)
    jnt_gp = pm.group(jnt_lst, name=tread_name + "JNTGP")
    pm.xform(gp, translation=loc_pos)
    pm.parent(control_crv, gp)
    pm.parent(jnt_gp, gp)
    # call to create expression function
    createTreadExpression(mtnPth=path_anim_list,
                          runAttr=str(control_crv[0]) + ".run",
                          speedAttr=str(control_crv[0]) + ".speed",
                          exp_nm=tread_name)
    return None