Exemple #1
0
def resizeControlShape(control,
                       size,
                       length=None,
                       nextControl=None,
                       lengthAxis='x'):

    control = ka_pymel.getAsPyNodes(control)

    if 'transform' in pymel.nodeType(control, inherits=True):
        controlShapes = control.getShapes()
        control = control

    else:
        controlShapes = control
        control = control.getParent()

    laticeDeformer, lattice, latticeBase = pymel.lattice(controlShapes)
    latticeShape = lattice.getShape()
    latticeBase.uDivisions.set(2)
    latticeBase.sDivisions.set(2)
    latticeBase.tDivisions.set(2)

    laticeDeformer.outsideLattice.set(1)
Exemple #2
0
def getStoredSelection():
    selection = ka_clipBoard.get('storedSelection', [])
    selection = ka_pymel.getAsPyNodes(selection)
    return selection
Exemple #3
0
def rnkBipiedAnimation():
    global RNK_BIPIED_MAP
    rigDict = NITROGEN_BIPIED_MAP
    rigDict = ka_pymel.getAsPyNodes(rigDict)
    OOOOOOO = 'rigDict'
    print '%s: ' % OOOOOOO, eval(OOOOOOO), ' ', type(eval(OOOOOOO))
    # CENTER -----------------------------------------
    hip = rigDict.get('hip', None)
    pelvis = rigDict.get('pelvis', None)
    spines = rigDict.get('spines', None)
    necks = rigDict.get('necks', None)
    head = rigDict.get('head', None)

    # LEFT -----------------------------------------
    l_leg = rigDict.get('l_leg', None)
    l_knee = rigDict.get('l_knee', None)
    l_ankle = rigDict.get('l_ankle', None)
    l_footBall = rigDict.get('l_footBall', None)

    l_clavical = rigDict.get('l_clavical', None)
    l_arm = rigDict.get('l_arm', None)
    l_elbow = rigDict.get('l_elbow', None)
    l_wrist = rigDict.get('l_wrist', None)
    l_thumb = rigDict.get('l_thumb', None)
    l_fingers = rigDict.get('l_fingers', None)
    l_metacarpals = rigDict.get('l_metacarpals', None)

    # RIGHT -----------------------------------------
    r_leg = rigDict.get('r_leg', None)
    r_knee = rigDict.get('r_knee', None)
    r_ankle = rigDict.get('r_ankle', None)
    r_footBall = rigDict.get('r_footBall', None)

    r_clavical = rigDict.get('r_clavical', None)
    r_arm = rigDict.get('r_arm', None)
    r_elbow = rigDict.get('r_elbow', None)
    r_wrist = rigDict.get('r_wrist', None)
    r_thumb = rigDict.get('r_thumb', None)
    r_fingers = rigDict.get('r_fingers', None)
    r_metacarpals = rigDict.get('r_metacarpals', None)

    thumbCurlAxis = 'ry'
    flatThumbRotation = [0.0, -45.0, 0.0]

    pymel.currentTime(1)
    allControls = getAllControls_fromRigDict(rigDict)
    #for key in allControls:
    #if allControls[key] == None:
    #pymel.warning('%s has a value of None' % key)

    ka_animation.storeAllControls(allControls)
    ka_animation.deleteAnimationOnAllControls()

    # set A Pose ----------------------------------------------------------------
    ka_animation.keyAllControls()
    pymel.currentTime(0)  # count from zero, but first key is on frame 1

    pymel.select(clear=True)
    # set T Pose ----------------------------------------------------------------
    ka_animation.advanceNFrames(KEY_SPACING * 2)

    tryToXform(l_leg, rotation=[0, 0, -90], worldSpace=True)
    ka_transforms.mirrorTransform(r_leg, targetTransform=l_leg)

    tryToXform(l_knee, rotation=[0, 0, -90], worldSpace=True)
    ka_transforms.mirrorTransform(r_knee, targetTransform=l_knee)

    tryToXform(l_ankle, rotation=[0, 0, -90], worldSpace=True)
    ka_transforms.mirrorTransform(r_ankle, targetTransform=l_ankle)

    tryToXform(l_footBall, rotation=[90, 0, -90], worldSpace=True)
    ka_transforms.mirrorTransform(r_footBall, targetTransform=l_footBall)

    tryToXform(l_arm, rotation=[-180, 0, 0], worldSpace=True)
    ka_transforms.mirrorTransform(r_arm, targetTransform=l_arm)

    tryToXform(l_elbow, rotation=[-180, 0, 0], worldSpace=True)
    ka_transforms.mirrorTransform(r_elbow, targetTransform=l_elbow)

    tryToXform(l_wrist, rotation=[-180, 0, 0], worldSpace=True)
    ka_transforms.mirrorTransform(r_wrist, targetTransform=l_wrist)

    for iA, finger in enumerate(l_fingers):
        for iB, fingerJoint in enumerate(finger):
            tryToXform(l_fingers[iA][iB],
                       rotation=[-90, 0, 0],
                       worldSpace=True)
            ka_transforms.mirrorTransform(r_fingers[iA][iB],
                                          targetTransform=fingerJoint)

    for iA, thumbJoint in enumerate(l_thumb):
        #worldRot = pymel.xform(l_thumb[0], q=True, ws=True, rotation=True)
        if iA != 0:
            #pymel.xform(l_thumb[iA], ws=True, rotation=worldRot)
            ka_transforms.snap(l_thumb[iA], l_thumb[0], r=1)
            ka_transforms.mirrorTransform(r_thumb[iA],
                                          targetTransform=thumbJoint)

    for spine in spines:
        tryToXform(spine, rotation=[0, 0, 0], worldSpace=True)

    for neck in necks:
        tryToXform(neck, rotation=[0, 0, 0], worldSpace=True)

    tryToXform(head, rotation=[0, 0, 0], worldSpace=True)

    ka_animation.storePose('tPose')
    ka_animation.keyAllControls()

    #pymel.error()

    # FINGER CURLS ----------------------------------------------------------------
    ka_animation.advanceNFrames(KEY_SPACING)
    ka_animation.keyAllControls()

    #pymel.error()

    for iA, finger in enumerate(reversed(l_fingers)):

        # inward curl
        curl = 0
        for iB, fingerJoint in enumerate(finger):
            ka_animation.advanceNFrames(KEY_SPACING / 2)

            tryToXform(l_thumb[0], rotation=flatThumbRotation, worldSpace=True)
            ka_transforms.mirrorTransform(r_thumb[0],
                                          targetTransform=l_thumb[0])

            if iB == 0:
                curl = -75

            elif iB == 1:
                curl = -95

            else:
                curl = -65

            tryToXform(fingerJoint,
                       rotation=[0, 0, curl],
                       worldSpace=True,
                       relative=True)
            ka_transforms.mirrorTransform(r_fingers[iA][iB],
                                          targetTransform=fingerJoint)

            ka_animation.keyAllControls()

        ka_animation.advanceNFrames(KEY_SPACING)
        ka_animation.applyPose('tPose')

        tryToXform(
            l_thumb[0],
            rotation=flatThumbRotation,
            worldSpace=True,
        )
        ka_transforms.mirrorTransform(r_thumb[0], targetTransform=l_thumb[0])

        ka_animation.keyAllControls()

        # upward curl
        curl = 0
        for iB, fingerJoint in enumerate(finger):
            ka_animation.advanceNFrames(KEY_SPACING / 2)

            if iB == 0:
                curl = 40

            elif iB == 1:
                curl = 10

            else:
                curl = 15

            tryToXform(fingerJoint,
                       rotation=[0, 0, curl],
                       worldSpace=True,
                       relative=True)
            ka_transforms.mirrorTransform(r_fingers[iA][iB],
                                          targetTransform=fingerJoint)

            ka_animation.keyAllControls()

        ka_animation.advanceNFrames(KEY_SPACING / 2)
        ka_animation.applyPose('tPose')

        tryToXform(l_thumb[0], rotation=flatThumbRotation, worldSpace=True)
        ka_transforms.mirrorTransform(r_thumb[0], targetTransform=l_thumb[0])

        ka_animation.keyAllControls()

    ka_animation.advanceNFrames(KEY_SPACING / 2)
    ka_animation.applyPose('tPose')

    ka_animation.keyAllControls()

    # THUMB CURLS ----------------------------------------------------------------

    # innerCurl
    for iA, thumbJoint in enumerate(l_thumb):
        if iA == 0:
            #tryToXform(thumbJoint, rotation=[-90, -40, -30], worldSpace=True,)
            #ka_transforms.mirrorTransform(r_thumb[iA], targetTransform=l_thumb[iA])
            pass

        else:
            if iA == 1:
                curl = 60

            else:
                curl = 65

            rot = thumbJoint.attr(thumbCurlAxis).get()
            thumbJoint.attr(thumbCurlAxis).set(rot + curl)
            ka_transforms.mirrorTransform(r_thumb[iA],
                                          targetTransform=l_thumb[iA])

        ka_animation.keyAllControls()
        ka_animation.advanceNFrames(KEY_SPACING / 2)

    ka_animation.advanceNFrames(KEY_SPACING / 2)
    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()

    # outerCurl
    for iA, thumbJoint in enumerate(l_thumb):
        if iA == 0:
            #tryToXform(thumbJoint, rotation=[-45, -45, -40], worldSpace=True)
            pass
        else:
            if iA == 1:
                curl = -20

            else:
                curl = -65

            rot = thumbJoint.attr(thumbCurlAxis).get()
            thumbJoint.attr(thumbCurlAxis).set(rot + curl)
            ka_transforms.mirrorTransform(r_thumb[iA],
                                          targetTransform=l_thumb[iA])

        ka_animation.keyAllControls()
        ka_animation.advanceNFrames(KEY_SPACING / 2)

    ka_animation.advanceNFrames(KEY_SPACING / 2)
    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()

    # HAND CUP ----------------------------------------------------------------
    # metacarpals
    ka_animation.advanceNFrames(KEY_SPACING)
    for iA, metacarpal in enumerate(l_metacarpals):
        if iA == 0:
            rotation = [16, 0, -7]

        else:
            rotation = [-42, 0, -16]

        tryToXform(metacarpal,
                   rotation=[rotation[0], 0, 0],
                   worldSpace=True,
                   relative=True)
        tryToXform(metacarpal,
                   rotation=[0, 0, rotation[2]],
                   worldSpace=True,
                   relative=True)
        #metacarpal.r.set(rotation)
        ka_transforms.mirrorTransform(r_metacarpals[iA],
                                      targetTransform=l_metacarpals[iA])

    # thumb
    for iA, thumbJoint in enumerate(l_thumb):
        if iA == 0:
            tryToXform(thumbJoint, rotation=[-40, 0, -44], worldSpace=True)
            ka_transforms.mirrorTransform(r_thumb[0],
                                          targetTransform=l_thumb[0])

        else:
            if iA == 1:
                curl = 40

            else:
                curl = -57

            rotz = thumbJoint.rz.get()
            rotz = thumbJoint.rz.set(rotz + curl)
            ka_transforms.mirrorTransform(r_thumb[iA],
                                          targetTransform=l_thumb[iA])

    ka_animation.keyAllControls()

    ka_animation.advanceNFrames(KEY_SPACING)
    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()

    # HAND SPLAY ----------------------------------------------------------------
    # thumb
    tryToXform(l_thumb[0], rotation=[-95, -63, 7], worldSpace=True)
    ka_transforms.mirrorTransform(r_thumb[0], targetTransform=l_thumb[0])

    for iA, finger in enumerate(l_fingers):
        if iA == 0:
            splay = 21

        elif iA == 1:
            splay = 0

        elif iA == 2:
            splay = -15

        else:
            splay = -30

        for iB, fingerJoint in enumerate(finger):
            if iB == 0:
                ry = fingerJoint.ry.get()
                fingerJoint.ry.set(ry + splay)
                ka_transforms.mirrorTransform(
                    r_fingers[iA][iB], targetTransform=l_fingers[iA][iB])

    for iA, metacarpal in enumerate(l_metacarpals):
        if iA == 0:
            splay = -2

        else:
            splay = -6

        ry = metacarpal.ry.get()
        metacarpal.ry.set(ry + splay)
        ka_transforms.mirrorTransform(r_metacarpals[iA],
                                      targetTransform=l_metacarpals[iA])

    ka_animation.keyAllControls()

    ka_animation.advanceNFrames(KEY_SPACING)
    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()

    # WRIST ROTATIONS ----------------------------------------------------------------
    ka_animation.advanceNFrames(KEY_SPACING)

    # forward
    tryToXform(l_wrist, rotation=[-180, -32, 0], worldSpace=True)
    ka_transforms.mirrorTransform(r_wrist, targetTransform=l_wrist)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # back
    tryToXform(l_wrist, rotation=[-180, 50, 0], worldSpace=True)
    ka_transforms.mirrorTransform(r_wrist, targetTransform=l_wrist)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # up
    tryToXform(l_wrist, rotation=[-180, 0, -268], worldSpace=True)
    ka_transforms.mirrorTransform(r_wrist, targetTransform=l_wrist)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # down
    tryToXform(l_wrist, rotation=[-180, 0, -90], worldSpace=True)
    ka_transforms.mirrorTransform(r_wrist, targetTransform=l_wrist)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # forward
    tryToXform(l_wrist, rotation=[-180, -32, 0], worldSpace=True)
    ka_transforms.mirrorTransform(r_wrist, targetTransform=l_wrist)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # up
    tryToXform(l_wrist, rotation=[-180, 0, -268], worldSpace=True)
    ka_transforms.mirrorTransform(r_wrist, targetTransform=l_wrist)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # back
    tryToXform(l_wrist, rotation=[-180, 50, 0], worldSpace=True)
    ka_transforms.mirrorTransform(r_wrist, targetTransform=l_wrist)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # down
    tryToXform(l_wrist, rotation=[-180, 0, -90], worldSpace=True)
    ka_transforms.mirrorTransform(r_wrist, targetTransform=l_wrist)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # forward
    tryToXform(l_wrist, rotation=[-180, -32, 0], worldSpace=True)
    ka_transforms.mirrorTransform(r_wrist, targetTransform=l_wrist)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # ARM TWIST ----------------------------------------------------------------

    # twist back
    # wrist
    tryToXform(l_wrist, rotation=[-38, 0, 0], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_wrist, targetTransform=l_wrist)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # arm
    tryToXform(l_arm, rotation=[-38, 0, 0], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_arm, targetTransform=l_arm)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # twist forward
    # wrist
    tryToXform(l_wrist, rotation=[90, 0, 0], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_wrist, targetTransform=l_wrist)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # arm
    tryToXform(l_arm, rotation=[38, 0, 0], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_arm, targetTransform=l_arm)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # ELBOW BEND ----------------------------------------------------------------
    tryToXform(l_elbow, rotation=[0, -135, 0], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_elbow, targetTransform=l_elbow)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # ARM ROTATIONS ----------------------------------------------------------------
    # down
    tryToXform(l_arm, rotation=[0, 0, -90], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_arm, targetTransform=l_arm)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING / 2)

    # forward
    tryToXform(l_arm, rotation=[-90, 0, 0], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_arm, targetTransform=l_arm)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING / 2)

    # flat
    ka_animation.applyPose('tPose')
    ka_transforms.mirrorTransform(r_arm, targetTransform=l_arm)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING / 2)

    tryToXform(l_arm, rotation=[0, 0, 90], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_arm, targetTransform=l_arm)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING / 2)

    # back
    tryToXform(l_arm, rotation=[0, 90, 0], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_arm, targetTransform=l_arm)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING / 2)

    # down and back
    tryToXform(l_arm, rotation=[-45, 0, 0], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_arm, targetTransform=l_arm)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING / 2)
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING / 2)

    # down
    tryToXform(l_arm, rotation=[-90, 0, 0], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_arm, targetTransform=l_arm)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # SHOULDER ROTATIONS ISOLATED ----------------------------------------------------------------

    # up
    tryToXform(l_clavical, rotation=[0, 0, 35], worldSpace=True, relative=True)

    tryToXform(l_arm, rotation=[90, 0, -0], worldSpace=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # down
    tryToXform(l_clavical,
               rotation=[0, 0, -16],
               worldSpace=True,
               relative=True)

    tryToXform(l_arm, rotation=[90, 0, 0], worldSpace=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # forward
    tryToXform(l_clavical,
               rotation=[0, -60, 0],
               worldSpace=True,
               relative=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # back
    tryToXform(l_clavical, rotation=[0, 16, 0], worldSpace=True, relative=True)

    tryToXform(l_arm, rotation=[90, 0, 0], worldSpace=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # ARM OVER HEAD ----------------------------------------------------------------
    tryToXform(l_clavical, rotation=[0, 0, 35], worldSpace=True, relative=True)

    tryToXform(l_arm, rotation=[0, 0, 105], worldSpace=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # ARM CROSSOVER ----------------------------------------------------------------
    tryToXform(l_clavical,
               rotation=[0, -60, 0],
               worldSpace=True,
               relative=True)

    tryToXform(l_arm, rotation=[90, -155, 0], worldSpace=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # HEAD AND NECK ROTATIONS ----------------------------------------------------------------

    # look up
    tryToXform(head, rotation=[45, 0, 0], worldSpace=True, relative=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    for iA, neckJoint in enumerate(reversed(necks)):
        if iA == 0:
            tryToXform(neckJoint,
                       rotation=[20, 0, 0],
                       worldSpace=True,
                       relative=True)
        else:
            tryToXform(neckJoint,
                       rotation=[10, 0, 0],
                       worldSpace=True,
                       relative=True)

        ka_animation.keyAllControls()
        ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # look down
    tryToXform(head, rotation=[-35, 0, 0], worldSpace=True, relative=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    for iA, neckJoint in enumerate(reversed(necks)):
        if iA == 0:
            tryToXform(neckJoint,
                       rotation=[-15, 0, 0],
                       worldSpace=True,
                       relative=True)
        else:
            tryToXform(neckJoint,
                       rotation=[-7, 0, 0],
                       worldSpace=True,
                       relative=True)

        ka_animation.keyAllControls()
        ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # bend left
    tryToXform(head, rotation=[0, 0, 45], worldSpace=True, relative=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    for iA, neckJoint in enumerate(reversed(necks)):
        if iA == 0:
            tryToXform(neckJoint,
                       rotation=[0, 0, 20],
                       worldSpace=True,
                       relative=True)
        else:
            tryToXform(neckJoint,
                       rotation=[0, 0, 10],
                       worldSpace=True,
                       relative=True)

        ka_animation.keyAllControls()
        ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # bend right
    tryToXform(head, rotation=[0, 0, -45], worldSpace=True, relative=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    for iA, neckJoint in enumerate(reversed(necks)):
        if iA == 0:
            tryToXform(neckJoint,
                       rotation=[0, 0, -20],
                       worldSpace=True,
                       relative=True)
        else:
            tryToXform(neckJoint,
                       rotation=[0, 0, -10],
                       worldSpace=True,
                       relative=True)

        ka_animation.keyAllControls()
        ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # HEAD AND NECK TWIST ----------------------------------------------------------------
    twist = 105
    numberOfControls = 1 + len(necks)
    twistPerJoint = twist * (1.0 / numberOfControls)

    # twist left
    tryToXform(head,
               rotation=[0, twistPerJoint, 0],
               worldSpace=True,
               relative=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    for iA, neckJoint in enumerate(reversed(necks)):
        tryToXform(neckJoint,
                   rotation=[0, twistPerJoint, 0],
                   worldSpace=True,
                   relative=True)

        ka_animation.keyAllControls()
        ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # twist right
    twistPerJoint *= -1

    tryToXform(head,
               rotation=[0, twistPerJoint, 0],
               worldSpace=True,
               relative=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    for iA, neckJoint in enumerate(reversed(necks)):
        tryToXform(neckJoint,
                   rotation=[0, twistPerJoint, 0],
                   worldSpace=True,
                   relative=True)

        ka_animation.keyAllControls()
        ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # SPINE ROTATIONS ----------------------------------------------------------------

    # forward
    for iA, spineJoint in enumerate(reversed(spines)):
        if iA == 0:
            bend = -20
        else:
            bend = -30

        tryToXform(spineJoint,
                   rotation=[bend, 0, 0],
                   worldSpace=True,
                   relative=True)

        ka_animation.keyAllControls()
        ka_animation.advanceNFrames(KEY_SPACING / 2)

    ka_animation.advanceNFrames(KEY_SPACING / 2)
    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING / 2)

    # backward
    for iA, spineJoint in enumerate(reversed(spines)):
        if iA == 0:
            bend = 20
        else:
            bend = 30

        tryToXform(spineJoint,
                   rotation=[bend, 0, 0],
                   worldSpace=True,
                   relative=True)

        ka_animation.keyAllControls()
        ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.advanceNFrames(KEY_SPACING / 2)
    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING / 2)

    # bend left
    for iA, spineJoint in enumerate(reversed(spines)):
        if iA == 0:
            bend = 20
        else:
            bend = 30

        tryToXform(spineJoint,
                   rotation=[0, 0, bend],
                   worldSpace=True,
                   relative=True)

        ka_animation.keyAllControls()
        ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.advanceNFrames(KEY_SPACING / 2)
    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING / 2)

    # bend right
    for iA, spineJoint in enumerate(reversed(spines)):
        if iA == 0:
            bend = -20
        else:
            bend = -30

        tryToXform(spineJoint,
                   rotation=[0, 0, bend],
                   worldSpace=True,
                   relative=True)

        ka_animation.keyAllControls()
        ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.advanceNFrames(KEY_SPACING / 2)
    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING / 2)

    # SPINE TWIST ----------------------------------------------------------------
    twist = 90
    numberOfControls = len(spines)
    twistPerJoint = twist * (1.0 / numberOfControls)

    # left
    for iA, spineJoint in enumerate(reversed(spines)):
        tryToXform(spineJoint,
                   rotation=[0, twistPerJoint, 0],
                   worldSpace=True,
                   relative=True)

        ka_animation.keyAllControls()
        ka_animation.advanceNFrames(KEY_SPACING / 2)

    tryToXform(l_clavical, rotation=[0, 15, 0], worldSpace=True, relative=True)
    tryToXform(r_clavical, rotation=[0, 30, 0], worldSpace=True, relative=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING / 2)

    ka_animation.advanceNFrames(KEY_SPACING / 2)
    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING / 2)

    # right
    twistPerJoint *= -1

    for iA, spineJoint in enumerate(reversed(spines)):
        tryToXform(spineJoint,
                   rotation=[0, twistPerJoint, 0],
                   worldSpace=True,
                   relative=True)

        ka_animation.keyAllControls()
        ka_animation.advanceNFrames(KEY_SPACING / 2)

    tryToXform(l_clavical,
               rotation=[0, -30, 0],
               worldSpace=True,
               relative=True)
    tryToXform(r_clavical,
               rotation=[0, -15, 0],
               worldSpace=True,
               relative=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING / 2)

    ka_animation.advanceNFrames(KEY_SPACING / 2)
    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # PELVIS ----------------------------------------------------------------

    # forwards
    tryToXform(pelvis, rotation=[0, 0, -45], worldSpace=True, relative=True)
    tryToXform(
        l_leg,
        rotation=[90, 0, -90],
        worldSpace=True,
    )
    tryToXform(
        r_leg,
        rotation=[-90, 0, 90],
        worldSpace=True,
    )

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # backwards
    tryToXform(pelvis, rotation=[0, 0, 30], worldSpace=True, relative=True)
    tryToXform(
        l_leg,
        rotation=[90, 0, -90],
        worldSpace=True,
    )
    tryToXform(
        r_leg,
        rotation=[-90, 0, 90],
        worldSpace=True,
    )

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # left
    tryToXform(pelvis, rotation=[0, 0, -20], worldSpace=True, relative=True)
    tryToXform(
        l_leg,
        rotation=[90, 0, -90],
        worldSpace=True,
    )
    tryToXform(
        r_leg,
        rotation=[-90, 0, 90],
        worldSpace=True,
    )

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # right
    tryToXform(pelvis, rotation=[0, 0, 20], worldSpace=True, relative=True)
    tryToXform(
        l_leg,
        rotation=[90, 0, -90],
        worldSpace=True,
    )
    tryToXform(
        r_leg,
        rotation=[-90, 0, 90],
        worldSpace=True,
    )

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # twist right
    tryToXform(pelvis, rotation=[0, 30, 0], worldSpace=True, relative=True)
    tryToXform(
        l_leg,
        rotation=[90, 0, -90],
        worldSpace=True,
    )
    tryToXform(
        r_leg,
        rotation=[-90, 0, 90],
        worldSpace=True,
    )

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # twist left
    tryToXform(pelvis, rotation=[0, -30, 0], worldSpace=True, relative=True)
    tryToXform(
        l_leg,
        rotation=[90, 0, -90],
        worldSpace=True,
    )
    tryToXform(
        r_leg,
        rotation=[-90, 0, 90],
        worldSpace=True,
    )

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # TOES ----------------------------------------------------------------
    # up
    tryToXform(l_footBall,
               rotation=[-45, 0, 0],
               worldSpace=True,
               relative=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # down
    tryToXform(l_footBall, rotation=[30, 0, 0], worldSpace=True, relative=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # ANKLE ----------------------------------------------------------------
    # up
    tryToXform(l_ankle, rotation=[-15, 0, 0], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_ankle, targetTransform=l_ankle)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # down
    tryToXform(l_ankle, rotation=[60, 0, 0], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_ankle, targetTransform=l_ankle)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # outside
    tryToXform(l_ankle, rotation=[0, 0, -40], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_ankle, targetTransform=l_ankle)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # inside
    tryToXform(l_ankle, rotation=[0, 0, 30], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_ankle, targetTransform=l_ankle)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # KNEE ----------------------------------------------------------------
    tryToXform(l_knee, rotation=[90, 0, 0], worldSpace=True, relative=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # LEG ROTATION ----------------------------------------------------------------
    # fowards
    tryToXform(l_leg, rotation=[-90, 0, 0], worldSpace=True, relative=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # backwards
    tryToXform(l_leg, rotation=[90, 0, 0], worldSpace=True, relative=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # outside
    tryToXform(l_leg, rotation=[0, 0, 30], worldSpace=True, relative=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # inside
    tryToXform(l_leg, rotation=[0, 0, -65], worldSpace=True, relative=True)
    tryToXform(r_leg, rotation=[0, 0, -65], worldSpace=True, relative=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # fowards
    tryToXform(l_leg, rotation=[-90, 0, 0], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_leg, targetTransform=l_leg)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # outside
    tryToXform(l_leg, rotation=[0, 0, 30], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_leg, targetTransform=l_leg)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # backwards
    tryToXform(l_leg, rotation=[90, 0, 0], worldSpace=True, relative=True)
    ka_transforms.mirrorTransform(r_leg, targetTransform=l_leg)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # inside
    tryToXform(l_leg, rotation=[0, 0, -65], worldSpace=True, relative=True)
    tryToXform(r_leg, rotation=[0, 0, -65], worldSpace=True, relative=True)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # LEG TWIST ----------------------------------------------------------------

    # outside
    # ankle
    tryToXform(l_ankle, rotation=[0, -60, -0], worldSpace=True)
    ka_transforms.mirrorTransform(r_ankle, targetTransform=l_ankle)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # leg
    tryToXform(l_leg, rotation=[-10, 0, -90], worldSpace=True)
    ka_transforms.mirrorTransform(r_leg, targetTransform=l_leg)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # inside
    # ankle
    tryToXform(l_ankle, rotation=[0, -135, -0], worldSpace=True)
    ka_transforms.mirrorTransform(r_ankle, targetTransform=l_ankle)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # leg
    tryToXform(l_leg, rotation=[135, 0, -90], worldSpace=True)
    ka_transforms.mirrorTransform(r_leg, targetTransform=l_leg)

    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    ka_animation.applyPose('tPose')
    ka_animation.keyAllControls()
    ka_animation.advanceNFrames(KEY_SPACING)

    # Finish
    pymel.playbackOptions(min=1, max=pymel.currentTime(query=True) + 50)
    pymel.currentTime(1)