Exemplo n.º 1
0
    def resolveModelFilePath(cls, variant):
        '''
        This recursively searches for a model filepath given a proper folder structure and filename

        .. note:: 
            file names should be save in the model directory as follows: 
                "elementName_variant_model.ma"

        . example::
            ArchetypeBaseRig.resolveModelFilePath('base')

        :param variant: Name of the the variant you wish to search for.
        type variant: str
        '''
        elementDir = os.path.dirname(
            os.path.dirname(os.path.dirname(inspect.getfile(cls))))
        element = os.path.basename(elementDir)
        modelPath = joinPath(elementDir, 'model')
        filepath = joinPath(modelPath,
                            '{}_{}_model.ma'.format(element, variant))

        if not os.path.isfile(filepath):
            filepath = ""
            try:
                variant = cls.__bases__[0].__module__.split('.')[-1].split(
                    '_')[1]
                print variant
                return cls.__bases__[0].resolveModelFilePath(variant)
            except:
                traceback.print_exc()

        return filepath
Exemplo n.º 2
0
    def resolveDirPath(cls, dirname, variant):
        '''
        This will search for a given directory using the variant you pass. It will recursively
        go through all inherited classes until it finds a directory.

        .. example::
            ArchetypeBaseRig.resolveDirPath('skind_wts', 'base')

        :param dirname: Name of the directory you're looking for.
        :type dirname: str

        :param variant: Name of the the variant you wish to search for.
        type variant: str
        '''
        dirpath = joinPath(os.path.dirname(inspect.getfile(cls)), variant,
                           dirname)
        if not os.path.isdir(dirpath):
            dirpath = ""
            try:
                variant = cls.__bases__[0].__module__.split('.')[-1].split(
                    '_')[1]
                return cls.__bases__[0].resolveDirPath(dirname, variant)
            except:
                pass

        return dirpath
Exemplo n.º 3
0
    def buildExportPath(cls, dirname, variant):
        '''
        This will search for a given directory using the variant you pass. 

        .. example::
            ArchetypeBaseRig.buildExportPath('skind_wts', 'base')

        :param dirname: Name of the directory you're looking for.
        :type dirname: str

        :param variant: Name of the the variant you wish to search for.
        type variant: str
        '''
        dirpath = joinPath(os.path.dirname(inspect.getfile(cls)), variant,
                           dirname)
        return dirpath
Exemplo n.º 4
0
def exportBookmark(bookmarkName, path=1):
    bookmark = findBookmarkNode(bookmarkName)
    if not bookmark:
        print(bookMarkName + ' does not exist.')
        return False
    connections = mc.listConnections(bookmark + '.ni', p=1, c=1)
    # Disconect for export
    for i in xrange(0, len(connections), 2):
        nodeAttr = connections[i + 1]
        bookmarkAttr = connections[i]
        mc.disconnectAttr(nodeAttr, bookmarkAttr)
    mc.select(bookmark)
    filePath = joinPath(path, bookmarkName)
    print('Bookmark export', filePath)
    mc.file(filePath, es=1, force=1, typ='mayaAscii')

    # Reconnect
    for i in xrange(0, len(connections), 2):
        nodeAttr = connections[i + 1]
        bookmarkAttr = connections[i]
        mc.connectAttr(nodeAttr, bookmarkAttr)
Exemplo n.º 5
0
    def __init__(self, name, variant='base'):
        '''
        This is the constructor for the biped template. Here is where you will put nodes onto 
        the graph. 

        :param name: Name of the element you're using this for
        :type name: str

        :param variant: Name of the variant this template is being used for.
        :type variant: str
        '''

        super(BipedBaseRig, self).__init__(name, variant)

        animRigNode = self.getNodeByName("animRig")

        buildPath = joinPath(os.path.dirname(__file__), self.variant)

        # Parts
        #-------------------------------------------------------------------------------------------
        # BODY
        #-------------------------------------------------------------------------------------------
        # center
        spine = rigrepo.parts.spine.Spine(name='spine',
                                          jointList="mc.ls('spine_*_bind')")

        neck = rigrepo.parts.neck.Neck(name='neck',
                                       jointList="mc.ls('neck_?_bind')",
                                       anchor="chest_top")

        neckAddSpaceNode = rigrepo.nodes.addSpaceNode.AddSpaceNode(
            'addSpaces',
            attrNode="neck",
            constraintNode="neck_ort",
            parentNode='chest_top',
            targetList=['rig'],
            nameList=["world"],
            constraintType='orient')

        headAddSpaceNode = rigrepo.nodes.addSpaceNode.AddSpaceNode(
            'addHeadSpaces',
            attrNode="head",
            constraintNode="head_nul",
            parentNode='neck',
            targetList=['rig'],
            nameList=["world"],
            constraintType='orient')

        neck.addChildren([neckAddSpaceNode, headAddSpaceNode])

        # Arm
        l_arm = rigrepo.parts.arm.Arm("l_arm", [
            'clavicle_l_bind', 'shoulder_l_bind', 'elbow_l_bind',
            'wrist_l_bind'
        ],
                                      anchor='chest_top')
        l_arm.getAttributeByName("fkControls").setValue(
            ["shoulder_fk_l", "elbow_fk_l", "wrist_fk_l"])
        l_arm.getAttributeByName("ikControls").setValue(
            ["arm_pv_l", "arm_ik_l"])
        l_arm.getAttributeByName("paramNode").setValue("arm_L")
        l_arm.getAttributeByName("clavicleCtrl").setValue("clavicle_l")

        leftArmAddSpaceNode = rigrepo.nodes.addSpaceNode.AddSpaceNode(
            'addSpaces',
            attrNode="shoulderSwing_l",
            constraintNode="shoulderSwing_l_ort",
            parentNode='shoulderSwing_l_nul',
            targetList=['rig'],
            nameList=["world"],
            constraintType='orient')

        leftArmPvAddSpaceNode = rigrepo.nodes.addSpaceNode.AddSpaceNode(
            'pvAddSpaces',
            attrNode="arm_pv_l",
            constraintNode="arm_pv_l_nul",
            parentNode='l_arm',
            targetList=['chest_bind', 'wrist_fk_l_tgt'],
            nameList=["chest", "hand"],
            constraintType='parent')

        leftArmIkAddSpaceNode = rigrepo.nodes.addSpaceNode.AddSpaceNode(
            'ikAddSpaces',
            attrNode="arm_L",
            constraintNode="arm_ik_l_ort",
            parentNode='l_arm',
            targetList=['chest_bind', 'skull_bind', 'hip_swivel', 'hips_bind'],
            nameList=["chest", "head", "hips", "root"],
            constraintType='parent')

        l_hand = rigrepo.parts.hand.Hand("l_hand", [
            'ring_001_l_bind', 'middle_001_l_bind', 'index_001_l_bind',
            'pinkyCup_l_bind', 'thumbCup_l_bind'
        ])
        # Auto clavicle
        side = 'l'
        l_autoClav = rigrepo.parts.autoParent.AutoParent(
            side + '_autoClav',
            parentControl='clavicle_' + side,
            inputControls=['shoulderSwing_' + side, 'shoulder_fk_' + side],
            ikJointList=[
                'shoulder_fk_' + side, 'elbow_fk_' + side, 'wrist_fk_' + side
            ],
            autoBlendAttr='autoClav',
            side=side,
            ikBlendAttr=side + '_arm_rvr.output.outputX',
            anchor=side + '_arm_anchor_grp')

        # add hand to arm node.
        l_arm.addChildren([
            l_autoClav, leftArmAddSpaceNode, leftArmPvAddSpaceNode,
            leftArmIkAddSpaceNode, l_hand
        ])

        # Turning off until cycle is fixed
        l_autoClav.disable()
        r_arm = rigrepo.parts.arm.Arm("r_arm", [
            'clavicle_r_bind', 'shoulder_r_bind', 'elbow_r_bind',
            'wrist_r_bind'
        ],
                                      anchor='chest_top',
                                      side='r')

        r_arm.getAttributeByName("fkControls").setValue(
            ["shoulder_fk_r", "elbow_fk_r", "wrist_fk_r"])
        r_arm.getAttributeByName("ikControls").setValue(
            ["arm_pv_r", "arm_ik_r"])
        r_arm.getAttributeByName("paramNode").setValue("arm_R")
        r_arm.getAttributeByName("clavicleCtrl").setValue("clavicle_r")

        rightArmAddSpaceNode = rigrepo.nodes.addSpaceNode.AddSpaceNode(
            'addSpaces',
            attrNode="shoulderSwing_r",
            constraintNode="shoulderSwing_r_ort",
            parentNode='shoulderSwing_r_nul',
            targetList=['rig'],
            nameList=["world"],
            constraintType='orient')

        rightArmPvAddSpaceNode = rigrepo.nodes.addSpaceNode.AddSpaceNode(
            'pvAddSpaces',
            attrNode="arm_pv_r",
            constraintNode="arm_pv_r_nul",
            parentNode='r_arm',
            targetList=['chest_bind', 'wrist_fk_r_tgt'],
            nameList=["chest", "hand"],
            constraintType='parent')

        rightArmIkAddSpaceNode = rigrepo.nodes.addSpaceNode.AddSpaceNode(
            'ikAddSpaces',
            attrNode="arm_R",
            constraintNode="arm_ik_r_ort",
            parentNode='r_arm',
            targetList=['chest_bind', 'skull_bind', 'hip_swivel', 'hips_bind'],
            nameList=["chest", "head", "hips", "root"],
            constraintType='parent')

        r_hand = rigrepo.parts.hand.Hand("r_hand", [
            'ring_001_r_bind', 'middle_001_r_bind', 'index_001_r_bind',
            'pinkyCup_r_bind', 'thumbCup_r_bind'
        ], 'wrist_r_bind')

        # Auto clavicle
        side = 'r'

        r_autoClav = rigrepo.parts.autoParent.AutoParent(
            side + '_autoClav',
            parentControl='clavicle_' + side,
            inputControls=['shoulderSwing_' + side, 'shoulder_fk_' + side],
            ikJointList=[
                'shoulder_fk_' + side, 'elbow_fk_' + side, 'wrist_fk_' + side
            ],
            autoBlendAttr='autoClav',
            side=side,
            ikBlendAttr=side + '_arm_rvr.output.outputX',
            anchor=side + '_arm_anchor_grp')

        # add hand to arm node.
        r_arm.addChildren([
            r_autoClav, rightArmAddSpaceNode, rightArmPvAddSpaceNode,
            rightArmIkAddSpaceNode, r_hand
        ])

        # Turning off until cycle is fixed
        r_autoClav.disable()
        # Leg
        l_leg = rigrepo.parts.leg.Leg(
            "l_leg",
            ['pelvis_l_bind', 'thigh_l_bind', 'knee_l_bind', 'ankle_l_bind'],
            spine.getHipSwivelCtrl)

        l_leg.getAttributeByName("side").setValue("l")
        l_leg.getAttributeByName("fkControls").setValue(
            ["thigh_fk_l", "knee_fk_l", "ankle_fk_l"])
        l_leg.getAttributeByName("ikControls").setValue(
            ["leg_pv_l", "leg_ik_l"])
        l_leg.getAttributeByName("paramNode").setValue("leg_L")
        l_leg.getAttributeByName("clavicleCtrl").setValue("pelvis_l")

        l_foot = rigrepo.parts.foot.Foot(
            "l_foot", ['ankle_l_bind', 'ball_l_bind', 'toe_l_bind'],
            'ankle_fk_l_hdl',
            fkAnchor='ankle_fk_gimbal_l',
            ikAnchor='leg_ik_gimbal_l',
            anklePivot='ankle_l_pivot',
            ankleStretchTarget="ankle_fk_l_offset",
            ikfkGroup='l_leg_ikfk_grp',
            paramNodeName='leg_L')
        leftLegAddSpaceNode = rigrepo.nodes.addSpaceNode.AddSpaceNode(
            'pvAddSpaces',
            attrNode="leg_pv_l",
            constraintNode="leg_pv_l_nul",
            parentNode='rig',
            targetList=['pelvis_l', 'leg_ik_l'],
            nameList=["pelvis", "foot"],
            constraintType='parent')

        # add foot to the leg node
        l_leg.addChildren([l_foot, leftLegAddSpaceNode])

        r_leg = rigrepo.parts.leg.Leg(
            "r_leg",
            ['pelvis_r_bind', 'thigh_r_bind', 'knee_r_bind', 'ankle_r_bind'],
            spine.getHipSwivelCtrl,
            side="r")

        r_leg.getAttributeByName("side").setValue("r")
        r_leg.getAttributeByName("fkControls").setValue(
            ["thigh_fk_r", "knee_fk_r", "ankle_fk_r"])
        r_leg.getAttributeByName("ikControls").setValue(
            ["leg_pv_r", "leg_ik_r"])
        r_leg.getAttributeByName("paramNode").setValue("leg_R")
        r_leg.getAttributeByName("clavicleCtrl").setValue("pelvis_r")

        r_foot = rigrepo.parts.foot.Foot(
            "r_foot", ['ankle_r_bind', 'ball_r_bind', 'toe_r_bind'],
            'ankle_fk_r_hdl',
            fkAnchor='ankle_fk_gimbal_r',
            ikAnchor='leg_ik_gimbal_r',
            anklePivot='ankle_r_pivot',
            ankleStretchTarget="ankle_fk_r_offset",
            ikfkGroup='r_leg_ikfk_grp',
            paramNodeName='leg_R')

        rightLegAddSpaceNode = rigrepo.nodes.addSpaceNode.AddSpaceNode(
            'pvAddSpaces',
            attrNode="leg_pv_r",
            constraintNode="leg_pv_r_nul",
            parentNode='rig',
            targetList=['pelvis_r', 'leg_ik_r'],
            nameList=["pelvis", "foot"],
            constraintType='parent')

        # add foot to the leg node
        r_leg.addChildren([r_foot, rightLegAddSpaceNode])

        #-------------------------------------------------------------------------------------------
        # FACE
        #-------------------------------------------------------------------------------------------
        faceParts = rigrepo.parts.face.Face("face_parts")
        earClusterNode = rigrepo.nodes.utilNodes.ClusterControlNode("ears")
        earClusterNode.getAttributeByName("nameList").setValue(
            "['ear_l', 'ear_r']")
        earClusterNode.getAttributeByName("geometry").setValue("body_geo")
        earClusterNode.getAttributeByName("parent").setValue("face_upper")
        tongueNode = rigrepo.parts.tongue.Tongue(
            name='tongue', jointList="mc.ls('tongue_?_bind')", anchor="jaw")
        faceParts.addChildren([earClusterNode])
        l_blink = rigrepo.parts.blink.BlinkNew("l_blink", anchor="face_upper")
        r_blink = rigrepo.parts.blink.BlinkNew("r_blink",
                                               side="r",
                                               anchor="face_upper")
        r_blink.getAttributeByName("side").setValue("r")
        lookAtNode = rigrepo.parts.lookAt.LookAt("lookAt")
        mouth = rigrepo.parts.mouth.Mouth("mouth",
                                          lipMainCurve='lip_main_curve')
        mouth.getAttributeByName("orientFile").setValue(
            self.resolveDataFilePath('control_orients.data', self.variant))
        mouthBindGeometry = rigrepo.nodes.commandNode.CommandNode(
            'bindGeometry')
        mouthBindGeometryCmd = '''
import maya.cmds as mc
import rigrepo.libs.cluster
for curve in ["lip_main_curve", "lip_curve"]:
    wireDeformer = "{}_wire".format(curve)
    if mc.objExists(wireDeformer):
        mc.sets(mc.ls("body_geo.vtx[*]")[0], e=True, add="{}Set".format(wireDeformer))
        mc.rename(wireDeformer, curve.replace("_curve", "_wire"))
    else:
        wireDeformer = mc.wire("body_geo", gw=False, en=1.00, ce=0.00, li=0.00, 
                        w=curve, name=curve.replace("_curve", "_wire"))[0]
        # set the default values for the wire deformer
        mc.setAttr("{}.rotation".format(wireDeformer), 0)
        mc.setAttr("{}.dropoffDistance[0]".format(wireDeformer), 100)

bindJointList = list(set(mc.ls("lip_*_baseCurve_jnt")).difference(set(mc.ls("lip_main_*_baseCurve_jnt"))))
skinCluster = mc.skinCluster(*bindJointList + ["lip_curveBaseWire"],
                                rui=False,
                                tsb=True,
                                name="lip_curveBaseWire_skinCluster")[0]

for jnt in bindJointList:
    index = [int(s) for s in jnt.split("_") if s.isdigit()][0]
    mc.skinPercent(skinCluster, "lip_curveBaseWire.cv[{}]".format(index), tv=["lip_{}_baseCurve_jnt".format(index), 1])

for mesh in mc.ls(["lip_main_bindmesh", "lip_bindmesh", "mouth_corner_bindmesh"]):
    if mc.objExists(mesh) and mc.objExists("mouthMain_cls_hdl"):
        mc.select(mesh, r=True)
        cls = mc.cluster(name="{}_mouthMain_cluster".format(mesh), wn=['mouthMain_cls_hdl','mouthMain_cls_hdl'],bs=1)[0]
        rigrepo.libs.cluster.localize(cls, 'mouthMain_auto', 'model')
'''
        mouthBindGeometry.getAttributeByName('command').setValue(
            mouthBindGeometryCmd)
        mouth.addChildren([mouthBindGeometry])
        controlsDefaults = controlDefaultsNode.ControlDefaultsNode(
            "control_defaults",
            armControls=["*shoulder", "*elbow", "*wrist"],
            armParams=["arm_?"])
        l_brow = rigrepo.parts.brow.Brow("l_brow", anchor="head_tip")
        r_brow = rigrepo.parts.brow.Brow("r_brow", side="r", anchor="head_tip")
        r_brow_orient = rigrepo.nodes.commandNode.CommandNode('scaleOrients')
        r_brow_orientCmd = '''
import maya.cmds as mc
brow_orients = mc.ls("brow*_r_ort")
brow_nuls = mc.ls("brow*_r_nul")
brow_nul_parents = [mc.listRelatives(nul, p=True)[0] for nul in brow_nuls]
for nul, ort in zip(brow_nuls,brow_orients):
    mc.parent(nul, w=True)
    mc.setAttr("{}.sz".format(ort), -1)
    
for nul,parent in zip(brow_nuls, brow_nul_parents):
    mc.parent(nul, parent)
'''
        r_brow_orient.getAttributeByName('command').setValue(r_brow_orientCmd)
        r_brow.addChild(r_brow_orient)

        cheekClusterNode = rigrepo.nodes.utilNodes.ClusterControlNode("cheeks")
        cheekClusterNode.getAttributeByName("nameList").setValue(
            "['cheekPuff_l', 'cheekPuff_r', 'cheek_l', 'cheek_r']")
        cheekClusterNode.getAttributeByName("geometry").setValue("body_geo")
        cheekClusterNode.getAttributeByName("parent").setValue(
            "face_mid_driver")
        leftCheekLiftClusterNode = rigrepo.nodes.utilNodes.ClusterControlNode(
            "l_cheekLift")
        leftCheekLiftClusterNode.getAttributeByName("nameList").setValue(
            "['cheekLift_l']")
        leftCheekLiftClusterNode.getAttributeByName("geometry").setValue(
            "body_geo")
        leftCheekLiftClusterNode.getAttributeByName("parent").setValue(
            "lidLower_l")
        leftCheekLiftClusterNode.getAttributeByName("displayHandle").setValue(
            False)

        rightCheekLiftClusterNode = rigrepo.nodes.utilNodes.ClusterControlNode(
            "r_cheekLift")
        rightCheekLiftClusterNode.getAttributeByName("nameList").setValue(
            "['cheekLift_r']")
        rightCheekLiftClusterNode.getAttributeByName("geometry").setValue(
            "body_geo")
        rightCheekLiftClusterNode.getAttributeByName("parent").setValue(
            "lidLower_r")
        rightCheekLiftClusterNode.getAttributeByName("displayHandle").setValue(
            False)
        mouthCornerDistanceNode = rigrepo.nodes.commandNode.CommandNode(
            'mouthCornerDistance')
        mouthCornerDistanceNodeCmd = '''
import maya.cmds as mc
for side in ["l","r"]:
    distanceLoc = mc.createNode("transform", n="distance_loc_{}".format(side))
    mc.xform(distanceLoc, ws=True, matrix=mc.xform("eye_{}_bind".format(side), q=True, ws=True, matrix=True))
    mc.parent(distanceLoc, "face_upper")
    mouthCornerDCM = mc.createNode("decomposeMatrix", name="mouth_corner_{}_decomposeMatrix".format(side))
    distanceLocDCM = mc.createNode("decomposeMatrix", name="distance_loc_{}_decomposeMatrix".format(side))
    
    mc.connectAttr("mouth_corner_{}.worldMatrix[0]".format(side), "{}.inputMatrix".format(mouthCornerDCM))
    mc.connectAttr("distance_loc_{}.worldMatrix[0]".format(side), "{}.inputMatrix".format(distanceLocDCM))
    
    distanceNode = mc.createNode("distanceBetween", n="mouth_corner_{}_distance".format(side))
    mc.connectAttr("{}.outputTranslate".format(mouthCornerDCM), "{}.point1".format(distanceNode), f=True)
    mc.connectAttr("{}.outputTranslate".format(distanceLocDCM), "{}.point2".format(distanceNode), f=True)
        

    currentDistance = mc.getAttr("{}.distance".format(distanceNode))        
    for axis in ['x', 'y', 'z']:
        mc.setDrivenKeyframe("cheekPuff_{}_def_auto.s{}".format(side, axis), 
                                    cd="{}.distance".format(distanceNode), v=1, dv=currentDistance)
        mc.setDrivenKeyframe("cheekPuff_{}_def_auto.s{}".format(side, axis), 
                                    cd="{}.distance".format(distanceNode), v=2, dv=currentDistance-2)
                                    
                                    
        if axis == "y":
            mc.setDrivenKeyframe("cheek_{}_def_auto.t{}".format(side, axis), 
                                        cd="{}.distance".format(distanceNode), v=0, dv=currentDistance)
            mc.setDrivenKeyframe("cheek_{}_def_auto.t{}".format(side, axis), 
                                        cd="{}.distance".format(distanceNode), v=2, dv=currentDistance-2)

    # lid lower rotation
    mc.setDrivenKeyframe("lidLower_{}_def_auto.rx".format(side), 
                                    cd="{}.distance".format(distanceNode), v=0, dv=currentDistance)
    mc.setDrivenKeyframe("lidLower_{}_def_auto.rx".format(side), 
                                    cd="{}.distance".format(distanceNode), v=6, dv=currentDistance-2)

    if mc.objExists("cheekLift_{}_def_auto".format(side)):
        mc.setDrivenKeyframe("cheekLift_{}_def_auto.rx".format(side), 
                                        cd="{}.distance".format(distanceNode), v=0, dv=currentDistance)
        mc.setDrivenKeyframe("cheekLift_{}_def_auto.rx".format(side), 
                                        cd="{}.distance".format(distanceNode), v=6, dv=currentDistance-2)

        mc.addAttr("lidLower_{}".format(side), ln="cheekLift", at="double", keyable=True)
        mc.setDrivenKeyframe("cheekLift_{}.rx".format(side), 
                                        cd="lidLower_{}.cheekLift".format(side), v=0, dv=0)
        mc.setDrivenKeyframe("cheekLift_{}.rx".format(side), 
                                        cd="lidLower_{}.cheekLift".format(side), v=50, dv=10)
        mc.setDrivenKeyframe("cheekLift_{}.rx".format(side), 
                                        cd="lidLower_{}.cheekLift".format(side), v=-50, dv=-10)

        # turn off display handles for cheek lift
        mc.setAttr("cheekLift_{}_def_auto.displayHandle".format(side), 0)
                
'''
        mouthCornerDistanceNode.getAttributeByName('command').setValue(
            mouthCornerDistanceNodeCmd)
        cheekClusterNode.addChildren([
            leftCheekLiftClusterNode, rightCheekLiftClusterNode,
            mouthCornerDistanceNode
        ])

        # create both face and body builds
        bodyBuildNode = pubs.pNode.PNode("body")
        faceBuildNode = pubs.pNode.PNode("face")

        browsNode = pubs.pNode.PNode("brows")
        browsNode.addChildren([l_brow, r_brow])

        eyesNode = pubs.pNode.PNode("eyes")
        eyesNode.addChildren([l_blink, r_blink, lookAtNode])

        # add nodes ass children of body
        bodyBuildNode.addChildren([spine, neck, l_arm, r_arm, l_leg, r_leg])
        faceBuildNode.addChildren([
            faceParts, tongueNode, browsNode, eyesNode, mouth, cheekClusterNode
        ])

        bindMeshCurvePairs = """[
('blinkUpper_l_curve', 'blinkUpper_l'),
('blinkUpper_r_curve', 'blinkUpper_r'),
('blinkLower_l_curve', 'blinkLower_l'),
('blinkLower_r_curve', 'blinkLower_r')
]"""

        # bindmeshes
        bindMeshesNode = self.getNodeByName('bindMeshes')
        lidBindMeshNode = rigrepo.nodes.buildBindMeshNode.BuildBindMeshNode(
            'face', curves=bindMeshCurvePairs)

        bindMeshesNode.addChild(lidBindMeshNode)

        # get the postBuild node
        postBuild = animRigNode.getChild('postBuild')

        switchExpression = rigrepo.nodes.utilNodes.SwitchExpressionNode(
            "SwitchExpression")
        postBuild.addChild(switchExpression)
        switchExpression.disable()

        applyNode = animRigNode.getChild('apply')
        applyNode.addChild(controlsDefaults)

        applyDeformerNode = applyNode.getChild('deformers')
        bindmeshTransferSkinWtsNode = rigrepo.nodes.transferDeformer.TransferDeformerBindmesh(
            'bindmesh',
            source="body_geo",
            target=["lid*_bindmesh", "lip*_bindmesh", "mouth*_bindmesh"],
            deformerTypes=["skinCluster"],
            surfaceAssociation="closestPoint")
        bindmeshTransferClusterBlinksNode = rigrepo.nodes.transferDeformer.TransferClusterBlinks(
            'transferBlinkClusters', source="body_geo")
        bindmeshTransferClusterLidsNode = rigrepo.nodes.transferDeformer.TransferClusterLids(
            'transferLidsClusters', source="body_geo")
        freezeWireNode = rigrepo.nodes.goToRigPoseNode.GoToFreezePoseNode(
            'freezeWire')
        freezeWireExpression = rigrepo.nodes.utilNodes.FreezeWireExpressionNode(
            "FreezeWireExpression")

        freezeWireNode.addChild(freezeWireExpression)

        lipYankNode = rigrepo.nodes.yankClusterNode.YankClusterNode(
            'WireToClusters',
            clusters=
            '[trs+"_cluster" for trs in mc.ls("lip_*.__control__", o=True)]',
            transforms='mc.ls("lip_*.__control__", o=True)',
            selected=False,
            geometry="body_geo")

        applyWireNode = applyDeformerNode.getChild("wire")
        applyWireNode.addChildren([freezeWireNode, lipYankNode])

        applyDeformerNode.addChildren([bindmeshTransferSkinWtsNode], 1)
        applyDeformerNode.addChildren([
            bindmeshTransferClusterBlinksNode, bindmeshTransferClusterLidsNode
        ], 4)

        # create a build node to put builds under.
        buildNode = pubs.pNode.PNode("build")
        # add nodes to the build
        buildNode.addChildren([bodyBuildNode, faceBuildNode])

        # add children to the animRigNode
        animRigNode.addChildren([buildNode], index=postBuild.index())

        l_leg.getAttributeByName('anchor').setValue('hip_swivel')
        r_leg.getAttributeByName('anchor').setValue('hip_swivel')
Exemplo n.º 6
0
    def __init__(self, name, element='archetype', variant='base'):
        super(ArchetypeBaseRig, self).__init__(name)

        self.element = element
        self.variant = variant

        buildPath = joinPath(os.path.dirname(inspect.getfile(self.__class__)),
                             self.variant)
        animRigNode = self.addNode("animRig")

        # New Scene
        newSceneNode = rigrepo.nodes.newSceneNode.NewSceneNode('newScene')

        # Rig Sets
        rigSetsNode = rigrepo.nodes.commandNode.CommandNode('rigSets')
        cmd = """
import maya.cmds as mc
mc.sets(empty=1, n='RigSets')
        """
        rigSetsNode.getAttributeByName('command').setValue(cmd)

        # Load
        loadNode = pubs.pNode.PNode('load')

        # Load Model
        modelFileNode = rigrepo.nodes.loadFileNode.LoadFileNode(
            "model", filePath=self.resolveModelFilePath(self.variant))
        # Add model geo to RigSets
        modelFileCMD = modelFileNode.getAttributeByName('command').getValue()
        cmd = '''
if mc.objExists('RigSets') & mc.objExists('model'):
    mc.sets('model', add='RigSets')
        '''
        modelFileNode.getAttributeByName('command').setValue(modelFileCMD +
                                                             cmd)

        skeletonFileNode = rigrepo.nodes.loadFileNode.LoadFileNode(
            "skeleton",
            filePath=self.resolveDataFilePath('skeleton.ma', self.variant))
        jointDataNode = rigrepo.nodes.importDataNode.ImportDataNode(
            'jointPositions',
            dataFile=self.resolveDataFilePath('joint_positions.data',
                                              self.variant),
            dataType='joint',
            apply=True)
        labelJointsForMirroringNode = rigrepo.nodes.labelJointsForMirroringNode.LabelJointsForMirroringNode(
            'labelJointsForMirroring')

        jointDataNode.addChild(labelJointsForMirroringNode)

        # Curve
        curveFileNode = rigrepo.nodes.loadFileNode.LoadFileNode(
            "curves",
            filePath=self.resolveDataFilePath('curves.ma', self.variant))
        curveDataNode = rigrepo.nodes.importDataNode.ImportDataNode(
            'curvePosition',
            dataFile=self.resolveDataFilePath('curve_positions.data',
                                              self.variant),
            dataType='curve',
            apply=True)

        # Bind meshes
        bindMeshes = pubs.pNode.PNode('bindMeshes')

        importPSDDeltaNode = rigrepo.nodes.importPSDNode.ImportPSDDirNode(
            "psdDeltas",
            dirPath=self.resolveDirPath('psd', self.variant),
            loadDeltas=True,
            psdNames='["blinks", "skin"]')
        loadNode.addChildren([
            modelFileNode, skeletonFileNode, jointDataNode, curveFileNode,
            curveDataNode, bindMeshes, importPSDDeltaNode
        ])

        # postBuild
        postBuild = pubs.pNode.PNode("postBuild")

        # Create curve for the trs_shot
        trsCurve = rigrepo.nodes.commandNode.CommandNode('trsCurve')
        trsCurveCMD = """
import maya.cmds as mc
import rigrepo.libs.control  
if mc.objExists('trs_shot'):
    rigrepo.libs.control.create(name='trs_shot', controlType='circle', hierarchy=None)
        """
        trsCurve.getAttributeByName('command').setValue(trsCurveCMD)

        controlOrientDataNode = rigrepo.nodes.importDataNode.ImportDataNode(
            'controlOrients',
            dataFile=self.resolveDataFilePath('control_orients.data',
                                              self.variant),
            dataType='node',
            apply=True)

        controlDataNode = rigrepo.nodes.importDataNode.ImportDataNode(
            'controlPositions',
            dataFile=self.resolveDataFilePath('control_positions.data',
                                              self.variant),
            dataType='curve',
            attributes="['cvPositions', 'rotateOrder', 'color']",
            apply=True)

        controlOrientDataNode.getAttributeByName("Nodes").setValue(
            "mc.ls('*_ort',type='transform')")
        controlDataNode.getAttributeByName("Nodes").setValue(
            "rigrepo.libs.control.getControls()")

        tagControllersNode = rigrepo.nodes.commandNode.CommandNode(
            'tagControllers')
        tagControllersCmd = '''
import maya.cmds as mc
import maya.mel as mm

import rigrepo.libs.control

controls = rigrepo.libs.control.getControls()

mc.select(controls)
mm.eval('TagAsController')

# --------------------------------------------------
# Pickwalking
# --------------------------------------------------

# Face upper children - note: excluding 'eyeSocket_l', 'eyeSocket_r' because it is making the lide tweakers not go all the way around
children = ['face_lower', 'head_tip',  'cheek_r', 'cheek_l', 'nose_bridge']
parent = 'head'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

# Lid Tweakers

children = [u'lid_up_3_l', u'lid_up_4_l', u'lid_up_5_l', u'lid_corner_outer_l', u'lid_low_6_l', u'lid_low_5_l', u'lid_low_4_l', u'lid_low_3_l', u'lid_low_2_l', u'lid_corner_inner_l', u'lid_up_1_l', u'lid_up_2_l']
parent = 'lidLower_l'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

children = [u'lid_up_3_r', u'lid_up_2_r', u'lid_up_1_r', u'lid_corner_inner_r', u'lid_low_2_r', u'lid_low_3_r', u'lid_low_4_r', u'lid_low_5_r', u'lid_low_6_r', u'lid_corner_outer_r', u'lid_up_5_r', u'lid_up_4_r']
parent = 'lidLower_r'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

# Upper lids
children = ['lidLower_l']
parent = 'lidUpper_l'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

children = ['lidLower_r']
parent = 'lidUpper_r'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

# Lower lids
children = ['lidUpper_l']
parent = 'eyeSocket_l'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

children = ['lidUpper_r']
parent = 'eyeSocket_r'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

# Brows

children = [u'brow_peak_r', u'brow_main_r', u'brow_corrugator_r', u'brow_inner_r', u'brow_inner_l', u'brow_corrugator_l', 'brow_main_l', u'brow_peak_l']
parent = 'head_tip'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

# lip tweakers
children = [u'lip_center_up', u'lip_up_2_l', u'lip_up_1_l', u'lip_up_0_l', u'lip_corner_l', u'lip_low_0_l', u'lip_low_1_l', u'lip_low_2_l', u'lip_center_low', u'lip_low_2_r', u'lip_low_1_r', u'lip_low_0_r', u'lip_corner_r', u'lip_up_0_r', u'lip_up_1_r', u'lip_up_2_r']
parent = 'lip_lower'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

# Lip lower
children = ['lip_lower']
parent = 'lip_upper'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

# Lip upper and mouth corners
children = ['mouth_corner_r', 'mouth_corner_l']
parent = 'mouthMain'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

# Mouth main and tongue base - 'lip_upper' removed 
children = ['mouthMain', 'tongue_base', 'teeth_upper']
parent = 'jaw'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

# Tongue mid
children = ['tongue_mid']
parent = 'tongue_base'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

# Tongue tip
children = ['tongue_tip']
parent = 'tongue_mid'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

# Lower teeth
children = ['teeth_lower']
parent = 'teeth_upper'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

# Nose and sneers
children = ['sneer_r', 'sneer_l', 'nose', ]
parent = 'nose_bridge'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

# Cheek puff
children = ['cheekPuff_l']
parent = 'cheek_l'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

children = ['cheekPuff_r']
parent = 'cheek_r'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

# Head wire mid
children = ['headwire_mid']
parent = 'headwire_top'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

# Head wire low
children = ['headwire_low']
parent = 'headwire_mid'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

# jaw
children = ['jaw']
parent = 'face_lower'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

# face upper and head wire top
children = ['headwire_top', 'face_upper']
parent = 'head'
if mc.objExists(parent):
    mc.select(mc.ls(children), parent)
    mm.eval('TagAsControllerParent')

pickwalk = [

# Hands
[u'thumbCup_l',   u'thumb_001_l',  u'thumb_002_l',  u'thumb_003_l'],
[u'index_001_l',  u'index_002_l',  u'index_003_l',  u'index_004_l'],
[u'middle_001_l', u'middle_002_l', u'middle_003_l', u'middle_004_l'],
[u'ring_001_l',   u'ring_002_l',   u'ring_003_l',   u'ring_004_l'],
[u'pinky_001_l',  u'pinky_002_l',  u'pinky_003_l', u'pinky_004_l'],
['wrist_fk_gimbal_l', ['thumbCup_l', 'index_001_l', 'middle_001_l', 'ring_001_l', 'pinky_001_l']],

[u'thumbCup_r',   u'thumb_001_r',  u'thumb_002_r',  u'thumb_003_r'],
[u'index_001_r',  u'index_002_r',  u'index_003_r',  u'index_004_r'],
[u'middle_001_r', u'middle_002_r', u'middle_003_r', u'middle_004_r'],
[u'ring_001_r',   u'ring_002_r',   u'ring_003_r',   u'ring_004_r'],
[u'pinky_001_r',  u'pinky_002_r',  u'pinky_003_r', u'pinky_004_r'],
['wrist_fk_gimbal_r', ['thumbCup_r', 'index_001_r', 'middle_001_r', 'ring_001_r', 'pinky_001_r']],

# Arms
[u'clavicle_l', u'shoulderSwing_l', u'shoulder_fk_l', u'elbow_fk_l', u'wrist_fk_l', u'wrist_fk_gimbal_l'],
[u'clavicle_r', u'shoulderSwing_r', u'shoulder_fk_r', u'elbow_fk_r', u'wrist_fk_r', u'wrist_fk_gimbal_r'],

# Arm Bend bows
[u'arm_bend_0_l', u'arm_bend_1_l', u'arm_bend_2_l', u'arm_bend_3_l', u'arm_bend_4_l'],
[u'arm_bend_0_r', u'arm_bend_1_r', u'arm_bend_2_r', u'arm_bend_3_r', u'arm_bend_4_r'],

# Legs
[ u'thighSwing_l', u'leg_pv_l', u'leg_ik_l', u'leg_ik_gimbal_l', u'heel_l', u'ballRoll_l', u'ball_l_fk', u'toe_l'],
[ u'thighSwing_r', u'leg_pv_r', u'leg_ik_r', u'leg_ik_gimbal_r', u'heel_r', u'ballRoll_r', u'ball_r_fk', u'toe_r'],

# Leg bendbows
[u'leg_bend_0_l', u'leg_bend_1_l', u'leg_bend_2_l', u'leg_bend_3_l', u'leg_bend_4_l'],
[u'leg_bend_0_r', u'leg_bend_1_r', u'leg_bend_2_r', u'leg_bend_3_r', u'leg_bend_4_r'],

# Spine
[u'head', u'neck', u'chest_top', u'chest', u'torso', u'hip_swivel', u'hips'],

# Clavs to chest
['chest', ['clavicle_r', 'clavicle_l']],

# pelvis to hips
['hips', ['thighSwing_r', 'thighSwing_l']],

]

for data in pickwalk:
    if not isinstance(data[0], str): 
        for i in range(len(data)):
            if i < len(data)-1:
                parent = data[i]
                child = data[i+1]  
                if mc.objExists(parent):
                    mc.select(mc.ls(children), parent)
                    mm.eval('TagAsControllerParent')
    else:
        parent = data[0]
        children = data[1]
        if mc.objExists(parent):
            mc.select(mc.ls(children), parent)
            mm.eval('TagAsControllerParent')
        
'''
        tagControllersNode.getAttributeByName('command').setValue(
            tagControllersCmd)
        postBuild.addChild(trsCurve)
        postBuild.addChild(controlOrientDataNode)
        postBuild.addChild(controlDataNode)
        postBuild.addChild(tagControllersNode)

        #perspective frame
        frameNode = rigrepo.nodes.commandNode.CommandNode('frameCamera')
        frameNode.getAttributeByName('command').setValue(
            'import maya.cmds as mc\nmc.select(cl=1)\nmc.viewFit("persp")')

        # apply data
        applyNode = pubs.pNode.PNode("apply")
        deformersNode = pubs.pNode.PNode("deformers")

        # apply
        skinWtsFileNode = rigrepo.nodes.loadWtsDirNode.LoadWtsDirNode(
            "skinCluster",
            dirPath=self.resolveDirPath('skin_wts', self.variant))
        wireWtsFileNode = rigrepo.nodes.loadWtsDirNode.LoadWtsDirNode(
            "wire", dirPath=self.resolveDirPath('wire_wts', self.variant))
        clusterWtsFileNode = rigrepo.nodes.loadWtsDirNode.LoadWtsDirNode(
            "cluster",
            dirPath=self.resolveDirPath('cluster_wts', self.variant))
        importPSDSystemNode = rigrepo.nodes.importPSDNode.ImportPSDDirNode(
            "psd",
            dirPath=self.resolveDirPath('psd', self.variant),
            psdNames='["blinks", "skin"]')
        importSdkDataNode = rigrepo.nodes.importDataNode.ImportDataNode(
            'sdk',
            dataFile=self.resolveDataFilePath('sdk.data', self.variant),
            dataType='sdk',
            apply=True)
        importDeformerDataNode = rigrepo.nodes.importDataNode.ImportDataNode(
            'deformerOrder',
            dataFile=self.resolveDataFilePath('deformer_order.data',
                                              self.variant),
            dataType='deformerOrder',
            apply=True)

        skinWtsFileNode = rigrepo.nodes.loadWtsDirNode.LoadWtsDirNode(
            "skinCluster",
            dirPath=self.resolveDirPath('skin_wts', self.variant),
            excludeFilter='_bindmesh')

        bindmeshWtsFileNode = rigrepo.nodes.loadWtsDirNode.LoadWtsDirNode(
            "bindmeshLoad",
            dirPath=self.resolveDirPath('skin_wts', self.variant),
            includeFilter='_bindmesh')

        deltaMushWtsFileNode = rigrepo.nodes.loadWtsDirNode.LoadWtsDirNode(
            "deltaMush",
            dirPath=self.resolveDirPath('deltaMush_wts', self.variant))
        applyNode.addChildren(
            [deformersNode, importDeformerDataNode, importSdkDataNode])
        deformersNode.addChildren([
            skinWtsFileNode, wireWtsFileNode, clusterWtsFileNode,
            importPSDSystemNode, deltaMushWtsFileNode, bindmeshWtsFileNode
        ])

        importNodeEditorBookmarsNode = rigrepo.nodes.importNodeEditorBookmarksNode.ImportNodeEditorBookmarksNode(
            "bookmarks",
            dirPath=self.resolveDirPath('bookmarks', self.variant))
        importNodeEditorBookmarsNode.disable()

        # this will make sure that if the skinCluster is DQ it will support nonRigidScale
        setDqScaleNode = rigrepo.nodes.commandNode.CommandNode('NonRigidScale')
        setDqScaleNodeCmd = '''
import maya.cmds as mc        
for skinCluster in mc.ls(type="skinCluster"):
    mc.setAttr("%s.dqsSupportNonRigid" % skinCluster, 1)
'''
        setDqScaleNode.getAttributeByName("command").setValue(
            setDqScaleNodeCmd)
        skinWtsFileNode.addChild(setDqScaleNode)

        # --------------------------------------------------------------------------------------------------------------
        # Delivery
        # --------------------------------------------------------------------------------------------------------------
        deliveryNode = pubs.pNode.PNode("delivery")
        deliveryNode.disable()

        localizeNode = rigrepo.nodes.commandNode.CommandNode('localize')
        localizeNodeCmd = '''
import rigrepo.libs.skinCluster
import rigrepo.libs.cluster
import maya.cmds as mc

rigrepo.libs.skinCluster.localize(mc.ls(type="skinCluster"), "model")

# localize lid blink clusters
# This is hard coded, may want to take a look at this later.
lidClusters = mc.ls("lid*blink*cluster")
for cluster in lidClusters:
    clusterName = cluster.split("__")[-1]
    rigrepo.libs.cluster.localize(cluster, "{}_auto".format(clusterName), "model")
'''
        localizeNode.getAttributeByName('command').setValue(localizeNodeCmd)

        lockNode = rigrepo.nodes.commandNode.CommandNode('lockNodes')
        lockNodeCmd = '''
import rigrepo.libs.control
import rigrepo.libs.attribute
import maya.cmds as mc

# we shouldn't be locking translates of joints effected by ikHandles
ikJointList = list()
for hdl in mc.ls(type="ikHandle"):
    ikJointList.extend(mc.ikHandle(hdl, q=True, jl=True))
    
controls = rigrepo.libs.control.getControls()
lockNodes = set(mc.ls(type="transform")).difference(controls + [mc.listRelatives(shape, p=True)[0] for shape in mc.ls(type="camera")] + ikJointList)
for node in lockNodes:
    rigrepo.libs.attribute.lock(node, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz','t','r','s'])
    
for ctrl in controls:
    if mc.objExists(ctrl+'.jointOrient'):
        rigrepo.libs.attribute.lock(ctrl, ['jointOrient', 'rotateAxis', 'radius'])

for ctrl in mc.ls("mouth_corner_?"):
    rigrepo.libs.attribute.lockAndHide(ctrl, ['r', 'rx', 'ry', 'rz', 's', 'sx', 'sy', 'sz'])

for ctrl in mc.ls(("trs_master", "trs_shot", "trs_aux")):
    rigrepo.libs.attribute.lockAndHide(ctrl, ['v'])

rigrepo.libs.attribute.lockAndHide(mc.listRelatives("trs_master", p=True), ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz','t','r','s','v'])
'''
        lockNode.getAttributeByName('command').setValue(lockNodeCmd)

        hideHistoryNode = rigrepo.nodes.commandNode.CommandNode('hideHistory')
        hideHistoryNodeCmd = '''
import maya.cmds as mc    
excludeType = ("skinCluster","wire", "blendShape", "deltaMush", "cluster", "mesh", "nurbsCurve", "nurbsSurface")
exclude = []
for node in mc.ls("*"):
    if node not in exclude:
        mc.setAttr(node + '.isHistoricallyInteresting', 0)
        if mc.objectType(node) in excludeType:
            mc.setAttr(node + '.isHistoricallyInteresting', 1)
'''
        hideHistoryNode.getAttributeByName('command').setValue(
            hideHistoryNodeCmd)

        removeNodesNode = rigrepo.nodes.commandNode.CommandNode('removeNodes')
        removeNodesNodeCmd = '''
import maya.cmds as mc    
removeNodes = mc.ls(("poseFreeze", "lip_up_*cluster", "lip_low_*cluster", "lip_corner_*cluster", "lip_center_*cluster", "?_leg_*wire", "?_arm_*wire","brow*wire", "brow*curve"))

mc.delete(removeNodes)       
'''

        modelOverrideNode = rigrepo.nodes.commandNode.CommandNode(
            'modelOverride')
        modelOverrideCmd = '''
import maya.cmds as mc
mc.setAttr("{0}.overrideModel".format('model'), 1)
        '''
        modelOverrideNode.getAttributeByName('command').setValue(
            modelOverrideCmd)

        removeNodesNode.getAttributeByName('command').setValue(
            removeNodesNodeCmd)

        deliveryNode.addChildren([
            removeNodesNode, localizeNode, lockNode, hideHistoryNode,
            modelOverrideNode
        ])

        animRigNode.addChildren([
            newSceneNode, rigSetsNode, loadNode, postBuild, applyNode,
            deliveryNode, importNodeEditorBookmarsNode, frameNode
        ])

        # --------------------------------------------------------------------------------------------------------------
        # Workflow
        # --------------------------------------------------------------------------------------------------------------
        workflowNode = pubs.pNode.PNode('workflow')
        workflowNode.disable()
        self.addNode(workflowNode)

        # --------------------------------------------------------------------------------------------------------------
        # Workflow nodes Un-categorized
        # --------------------------------------------------------------------------------------------------------------

        # Model toggle
        modelToggleNode = rigrepo.nodes.modelOverrideToggleNode.ModelOverrideToggleNode(
            'modelOverride')
        # Rig Pose
        goToRigPoseNode = rigrepo.nodes.goToRigPoseNode.GoToRigPoseNode(
            'goToRigPose')
        workflowNode.addChildren([modelToggleNode, goToRigPoseNode])
        # Gpu Speed Key
        gpuSpeedKey = rigrepo.nodes.gpuSpeedKey.GpuSpeedKeyNode(
            'addGpuKeyframes')
        workflowNode.addChildren(
            [modelToggleNode, goToRigPoseNode, gpuSpeedKey])

        # Shape Authoring
        sculptingNode = pubs.pNode.PNode('sculpting')
        workflowNode.addChildren([sculptingNode])

        duplicateSubdivideNode = rigrepo.nodes.shapeAuthoringNode.ShapeAuthoringNode(
            'subdivide', action='duplicate')
        duplicateSubdivideToggleNode = rigrepo.nodes.shapeAuthoringNode.ShapeAuthoringNode(
            'subdivideToggle', action='toggle')
        duplicateSubdivideCommitNode = rigrepo.nodes.shapeAuthoringNode.ShapeAuthoringNode(
            'subdivideCommit', action='commit')
        extractFacesNode = rigrepo.nodes.shapeAuthoringNode.ShapeAuthoringNode(
            'extractFaces', action='extract')
        extractFacesCommitNode = rigrepo.nodes.shapeAuthoringNode.ShapeAuthoringNode(
            'extractFacesCommit', action='extractCommit')
        sculptingNode.addChildren([
            duplicateSubdivideNode, duplicateSubdivideToggleNode,
            duplicateSubdivideCommitNode, extractFacesNode,
            extractFacesCommitNode
        ])

        # Update Topology
        updateTopologyNode = pubs.pNode.PNode('updateTopology')
        workflowNode.addChildren([updateTopologyNode])

        updateTopologyRenameNode = rigrepo.nodes.updateTopologyNode.UpdateTopologyNode(
            'renameOld', action='rename')
        updateTopologyImportModelNode = rigrepo.nodes.loadFileNode.LoadFileNode(
            "importModel", filePath=self.resolveModelFilePath(self.variant))
        updateTopologyDeformersNode = pubs.pNode.PNode('transferDeformers')
        updateTopologySkinClusterNode = rigrepo.nodes.updateTopologyNode.UpdateTopologyNode(
            'skinCluster', action='skinCluster')
        updateTopologyClusterNode = rigrepo.nodes.updateTopologyNode.UpdateTopologyNode(
            'cluster', action='cluster')
        updateTopologyBlendShapeNode = rigrepo.nodes.updateTopologyNode.UpdateTopologyNode(
            'blendShape', action='blendShape')
        updateTopologyDeformersNode.addChildren([
            updateTopologyBlendShapeNode,
            updateTopologySkinClusterNode,
            updateTopologyClusterNode,
        ])
        updateTopologyReplaceNode = rigrepo.nodes.updateTopologyNode.UpdateTopologyNode(
            'replace', action='replace')

        updateTopologyNode.addChildren([
            updateTopologyRenameNode, updateTopologyImportModelNode,
            updateTopologyDeformersNode, updateTopologyReplaceNode
        ])
        # --------------------------------------------------------------------------------------------------------------
        # Workflow nodes grouped by action
        # --------------------------------------------------------------------------------------------------------------

        # EXPORTERS #
        exporters = pubs.pNode.PNode('exporters')
        # --------------------------------------------------------------------------------------------------------------
        jointExportDataNode = rigrepo.nodes.exportDataNode.ExportDataNode(
            'jointPositions',
            dataFile=self.buildExportPath('joint_positions.data',
                                          self.variant),
            dataType='joint')
        controlOrientsExportDataNode = rigrepo.nodes.exportDataNode.ExportDataNode(
            'controlOrients',
            dataFile=self.buildExportPath('control_orients.data',
                                          self.variant),
            dataType='node')
        controlOrientsExportDataNode.getAttributeByName("Nodes").setValue(
            'mc.ls("*_ort", type="transform")')
        curveExportDataNode = rigrepo.nodes.exportDataNode.ExportDataNode(
            'curvePositions',
            dataFile=self.buildExportPath('curve_positions.data',
                                          self.variant),
            dataType='curve')
        controlCurveExportDataNode = rigrepo.nodes.exportDataNode.ExportDataNode(
            'controlCurvePositions',
            dataFile=self.buildExportPath('control_positions.data',
                                          self.variant),
            dataType='controlCurve')
        sdkExportDataNode = rigrepo.nodes.exportDataNode.ExportDataNode(
            'sdk',
            dataFile=self.buildExportPath('sdk.data', self.variant),
            dataType='sdk')
        deformerOrderExportDataNode = rigrepo.nodes.exportDataNode.ExportDataNode(
            'deformerOrder',
            dataFile=self.buildExportPath('deformer_order.data', self.variant),
            dataType='deformerOrder')
        skinClusterExportWtsNode = rigrepo.nodes.exportWtsDirNode.ExportSkinWtsDirNode(
            'skinCluster',
            dirPath=self.buildExportPath('skin_wts', self.variant))
        wireExportWtsNode = rigrepo.nodes.exportWtsDirNode.ExportWtsDirNode(
            'wire',
            dirPath=self.buildExportPath('wire_wts', self.variant),
            deformerType="wire")
        clusterExportWtsNode = rigrepo.nodes.exportWtsDirNode.ExportWtsDirNode(
            'cluster',
            dirPath=self.buildExportPath('cluster_wts', self.variant),
            deformerType="cluster",
            excludeNodes=
            'mc.ls(["lip_*_?_?_*", "lip_corner_?_cluster", "lip_center_*_cluster", "lip*bindmesh*"],type="cluster")'
        )
        skinClusterExportWtsSelectedNode = rigrepo.nodes.exportWtsSelectedNode.ExportWtsSelectedNode(
            'skinClusterSelected',
            dirPath=self.buildExportPath('skin_wts', self.variant))
        #exportPSDNode = rigrepo.nodes.exportPSDNode.ExportPSDNode('psd',
        #                                                          dirPath=self.buildExportPath('psd', self.variant),
        #                                                          nodesExclude="['clavicle_l_auto_poseInterpolatorShape','clavicle_r_auto_poseInterpolatorShape']",
        #                                                          fileName='skin_psd')
        exportPSDByGroupsNode = rigrepo.nodes.exportPSDNode.ExportPSDByGroupNode(
            'psd',
            dirPath=self.buildExportPath('psd', self.variant),
            groups='rigrepo.libs.psd.getAllGroups()')
        nodeEditorBookmarks = rigrepo.nodes.exportNodeEditorBookmarksNode.ExportNodeEditorBookmarsNode(
            'NodeEditorBookmarks',
            dirPath=self.buildExportPath('bookmarks', self.variant))
        nodeEditorBookmarks.disable()
        # --------------------------------------------------------------------------------------------------------------
        exporters.addChildren([
            controlOrientsExportDataNode, jointExportDataNode,
            curveExportDataNode, controlCurveExportDataNode, sdkExportDataNode,
            skinClusterExportWtsNode, skinClusterExportWtsSelectedNode,
            wireExportWtsNode, clusterExportWtsNode, exportPSDByGroupsNode,
            deformerOrderExportDataNode, nodeEditorBookmarks
        ])

        # Mirroring #
        mirroring = pubs.pNode.PNode('mirror')
        # --------------------------------------------------------------------------------------------------------------
        mirrorControlCurveNode = rigrepo.nodes.mirrorControlCurveNode.MirrorControlCurveNode(
            'controlCurves')
        mirrorWireCurveNode = rigrepo.nodes.mirrorWiresNode.MirrorWiresNode(
            'wireCurves')
        mirrorJointsNode = rigrepo.nodes.mirrorJointsNode.MirrorJointsNode(
            'joints')
        mirrorSkinClusterNode = rigrepo.nodes.mirrorSkinClusterNode.MirrorSkinClusterNode(
            'skinClusterSelected')
        mirrorWireDeformerNode = rigrepo.nodes.mirrorDeformerNode.MirrorDeformerNode(
            'wireDeformer', deformerType='wire')
        mirrorClusterNode = rigrepo.nodes.mirrorDeformerNode.MirrorDeformerNode(
            'clusters', deformerType='cluster')
        #mirrorBlendShapeNode = rigrepo.nodes.mirrorDeformerNode.MirrorDeformerNode('blendShapes', deformerType='blendShape')
        mirrorPSDNode = rigrepo.nodes.mirrorPSDNode.MirrorPSDNode(
            'psdSystems', action='system')
        mirrorOrients = rigrepo.nodes.commandNode.CommandNode('orients')
        mirrorOrientsCmd = '''
import maya.cmds as mc
import rigrepo.libs.transform
rigrepo.libs.transform.mirror (mc.ls(["lip*_l_ort"], type="transform"), search='_l_', replace='_r_', axis="x")
'''
        mirrorOrients.getAttributeByName('command').setValue(mirrorOrientsCmd)
        mirrorSDKNode = rigrepo.nodes.commandNode.CommandNode('sdk')
        mirrorSDKCmd = '''
import maya.cmds as mc
import rigrepo.libs.data.sdk_data as sdk_data
currentData = sdk_data.SdkData()
currentData.gatherDataIterate(mc.ls("*_l_def_auto*", type=["animCurveUU", "animCurveUA", "animCurveUL", "animCurveUT"]))
data = currentData.getData()
for k in data.keys():
    data[k.replace('_l_','_r_')] = data[k]

currentData.applyData(data.keys())
'''
        mirrorSDKNode.getAttributeByName('command').setValue(mirrorSDKCmd)
        #mirrorOrients = rigrepo.nodes.mirrorPSDNode.MirrorPSDNode('psd')
        # --------------------------------------------------------------------------------------------------------------
        mirroring.addChildren([
            mirrorControlCurveNode, mirrorWireCurveNode, mirrorJointsNode,
            mirrorSkinClusterNode, mirrorWireDeformerNode, mirrorClusterNode,
            mirrorOrients, mirrorPSDNode, mirrorSDKNode
        ])

        # --------------------------------------------------------------------------------------------------------------
        # Workflow nodes grouped by type
        # --------------------------------------------------------------------------------------------------------------

        # SkinCluster #
        skinClusterNode = pubs.pNode.PNode('skinCluster')
        # --------------------------------------------------------------------------------------------------------------
        yankSkinClusterNode = rigrepo.nodes.yankSkinClusterNode.YankSkinClusterNode(
            'yank')
        sc_mirrorSkinClusterNode = rigrepo.nodes.mirrorSkinClusterNode.MirrorSkinClusterNode(
            'mirror')
        sc_transferSkinClusterNode = rigrepo.nodes.transferDeformer.TransferDeformer(
            'transfer',
            source="body_geo",
            target=["gum_upper_geo"],
            deformerTypes=["skinCluster"],
            surfaceAssociation="closestPoint")
        sc_skinClusterExportWtsNode = copy.deepcopy(skinClusterExportWtsNode)
        sc_skinClusterExportWtsNode.setNiceName('export')
        sc_skinClusterExportSelectedWtsNode = copy.deepcopy(
            skinClusterExportWtsSelectedNode)
        sc_skinClusterExportSelectedWtsNode.setNiceName('exportSel')

        sc_removeLocalizeNode = rigrepo.nodes.commandNode.CommandNode(
            'removeLocalize')
        sc_removeLocalizeCmd = '''
import rigrepo.libs.skinCluster
import rigrepo.libs.cluster
import maya.cmds as mc

rigrepo.libs.skinCluster.removeLocalize(mc.ls(type="skinCluster"))
'''

        sc_removeLocalizeNode.getAttributeByName('command').setValue(
            sc_removeLocalizeCmd)

        # --------------------------------------------------------------------------------------------------------------
        skinClusterNode.addChildren([
            yankSkinClusterNode, sc_mirrorSkinClusterNode,
            sc_skinClusterExportWtsNode, sc_skinClusterExportSelectedWtsNode,
            sc_transferSkinClusterNode, sc_removeLocalizeNode
        ])

        # SDK #
        sdkNode = pubs.pNode.PNode('SDK')
        # --------------------------------------------------------------------------------------------------------------
        sdk_selectNode = rigrepo.nodes.commandNode.CommandNode('selectSDKs')
        sdk_selectCmd = '''
import maya.cmds as mc
mc.select(mc.ls("*_def_auto*", type=["animCurveUU", "animCurveUA", "animCurveUL", "animCurveUT"]))
        '''
        sdk_selectNode.getAttributeByName('command').setValue(sdk_selectCmd)
        sdk_mirrorNode = rigrepo.nodes.commandNode.CommandNode('mirror')
        sdk_mirrorNode.getAttributeByName('command').setValue(mirrorSDKCmd)
        sdk_exportNode = copy.deepcopy(sdkExportDataNode)
        sdk_exportNode.setNiceName('export')
        # --------------------------------------------------------------------------------------------------------------
        sdkNode.addChildren([sdk_selectNode, sdk_mirrorNode, sdk_exportNode])

        # --------------------------------------------------------------------------------------------------------------
        # PSD
        # --------------------------------------------------------------------------------------------------------------
        psdNode = pubs.pNode.PNode('psd')

        # --------------------------------------------------------------------------------------------------------------
        addPosePSDNode = rigrepo.nodes.addPosePSDNode.AddPosePSDNode('addPose')
        addUpdatePSDNode = rigrepo.nodes.addPosePSDNode.AddPosePSDNode(
            'updatePose', action='updatePose')
        psd_mirrorPSDNodes = rigrepo.nodes.mirrorPSDNode.MirrorPSDNode(
            'mirrorSystem', action='system')
        psd_mirrorPSDDeltaNode = rigrepo.nodes.mirrorPSDNode.MirrorPSDNode(
            'mirrorDeltas', action='deltas')
        psd_deletePSDDeltaNode = rigrepo.nodes.addPosePSDNode.AddPosePSDNode(
            'deleteDeltas', action='deleteDeltas')
        psd_exportPSDNode = copy.deepcopy(exportPSDByGroupsNode)
        psd_exportPSDNode.setNiceName('export')
        # --------------------------------------------------------------------------------------------------------------
        psdNode.addChildren([
            addPosePSDNode, addUpdatePSDNode, psd_mirrorPSDNodes,
            psd_mirrorPSDDeltaNode, psd_deletePSDDeltaNode, psd_exportPSDNode
        ])

        # joints
        jointsNode = pubs.pNode.PNode('joints')
        zeroJointsNode = rigrepo.nodes.zeroJointsNode.ZeroJointsNode(
            'zeroJoints')
        jnt_mirrorJointsNode = copy.deepcopy(mirrorJointsNode)
        jnt_mirrorJointsNode.setNiceName('mirror')
        jnt_jointExportDataNode = copy.deepcopy(jointExportDataNode)
        jnt_jointExportDataNode.setNiceName('export')
        jointsNode.addChildren(
            [zeroJointsNode, jnt_mirrorJointsNode, jnt_jointExportDataNode])

        # anim
        testPath = os.path.dirname(tests.__file__).replace("\\", "/")
        animNode = pubs.pNode.PNode('anim')

        # Clear anim
        clearAnimNode = rigrepo.nodes.commandNode.CommandNode('clearAnimation')
        clearAnimNodeCMd = '''
import maya.cmds as mc
import rigrepo.libs.control

controls = rigrepo.libs.control.getControls()
mc.cutKey(controls)
        '''
        clearAnimNode.getAttributeByName('command').setValue(clearAnimNodeCMd)
        animNode.addChildren([clearAnimNode])

        # Anim Tests
        animTestsNode = pubs.pNode.PNode('tests')
        animNode.addChildren([animTestsNode])

        # Dance Flip
        animTestDanceFlip2Node = rigrepo.nodes.importAnimationNode.ImportAnimationNode(
            'danceFlip',
            filePath=self.resolveDataFilePath('anim/dance_flip_2.atom',
                                              self.variant),
            remapFile=self.resolveDataFilePath('control.map', self.variant))
        animTestsNode.addChildren([animTestDanceFlip2Node])

        # Body Cali
        animTestBodyCaliNode = rigrepo.nodes.importAnimationNode.ImportAnimationNode(
            'bodyCali',
            filePath=self.resolveDataFilePath('anim/body_calisthenics_2.atom',
                                              self.variant),
            remapFile=self.resolveDataFilePath('control.map', self.variant))
        animTestsNode.addChildren([animTestBodyCaliNode])

        # add all of the nodes in order to the workflow node.
        workflowNode.addChildren([
            exporters, mirroring, skinClusterNode, psdNode, sdkNode,
            jointsNode, animNode
        ])
Exemplo n.º 7
0
    def __init__(self, name, variant='base'):
        super(ArchetypeBaseRig, self).__init__(name)

        self.element = self._name
        self.variant = variant

        buildPath = joinPath(os.path.dirname(inspect.getfile(self.__class__)),
                             self.variant)
        animRigNode = self.addNode("animRig")

        # New Scene
        newSceneNode = rigrepo.nodes.newSceneNode.NewSceneNode('newScene')

        # Load
        loadNode = pubs.pNode.PNode('load')

        modelFileNode = rigrepo.nodes.loadFileNode.LoadFileNode(
            "model", filePath=self.resolveModelFilePath(self.variant))
        skeletonFileNode = rigrepo.nodes.loadFileNode.LoadFileNode(
            "skeleton",
            filePath=self.resolveDataFilePath('skeleton.ma', self.variant))
        jointDataNode = rigrepo.nodes.importDataNode.ImportDataNode(
            'jointPositions',
            dataFile=self.resolveDataFilePath('joint_positions.data',
                                              self.variant),
            dataType='joint',
            apply=True)
        labelJointsForMirroringNode = rigrepo.nodes.labelJointsForMirroringNode.LabelJointsForMirroringNode(
            'labelJointsForMirroring')

        jointDataNode.addChild(labelJointsForMirroringNode)

        # Curve
        curveFileNode = rigrepo.nodes.loadFileNode.LoadFileNode(
            "curves",
            filePath=self.resolveDataFilePath('curves.ma', self.variant))
        curveDataNode = rigrepo.nodes.importDataNode.ImportDataNode(
            'curvePosition',
            dataFile=self.resolveDataFilePath('curve_positions.data',
                                              self.variant),
            dataType='curve',
            apply=True)

        # Bind meshes
        bindMeshes = pubs.pNode.PNode('bindMeshes')

        importPSDDeltaNode = rigrepo.nodes.importPSDNode.ImportPSDDirNode(
            "psdDeltas",
            dirPath=self.resolveDirPath('psd', self.variant),
            loadDeltas=True,
            psdNames='["blinks", "skin"]')
        loadNode.addChildren([
            modelFileNode, skeletonFileNode, jointDataNode, curveFileNode,
            curveDataNode, bindMeshes, importPSDDeltaNode
        ])

        # postBuild
        postBuild = pubs.pNode.PNode("postBuild")

        controlOrientDataNode = rigrepo.nodes.importDataNode.ImportDataNode(
            'controlOrients',
            dataFile=self.resolveDataFilePath('control_orients.data',
                                              self.variant),
            dataType='node',
            apply=True)

        controlDataNode = rigrepo.nodes.importDataNode.ImportDataNode(
            'controlPositions',
            dataFile=self.resolveDataFilePath('control_positions.data',
                                              self.variant),
            dataType='curve',
            attributes="['cvPositions']",
            apply=True)

        controlOrientDataNode.getAttributeByName("Nodes").setValue(
            "mc.ls('*_ort',type='transform')")
        controlDataNode.getAttributeByName("Nodes").setValue(
            "rigrepo.libs.control.getControls()")

        postBuild.addChild(controlOrientDataNode)
        postBuild.addChild(controlDataNode)

        #perspective frame
        frameNode = rigrepo.nodes.commandNode.CommandNode('frameCamera')
        frameNode.getAttributeByName('command').setValue(
            'import maya.cmds as mc\nmc.select(cl=1)\nmc.viewFit("persp")')

        # apply data
        applyNode = pubs.pNode.PNode("apply")
        deformersNode = pubs.pNode.PNode("deformers")

        # apply
        skinWtsFileNode = rigrepo.nodes.loadWtsDirNode.LoadWtsDirNode(
            "skinCluster",
            dirPath=self.resolveDirPath('skin_wts', self.variant))
        wireWtsFileNode = rigrepo.nodes.loadWtsDirNode.LoadWtsDirNode(
            "wire", dirPath=self.resolveDirPath('wire_wts', self.variant))
        clusterWtsFileNode = rigrepo.nodes.loadWtsDirNode.LoadWtsDirNode(
            "cluster",
            dirPath=self.resolveDirPath('cluster_wts', self.variant))
        importPSDSystemNode = rigrepo.nodes.importPSDNode.ImportPSDDirNode(
            "psd",
            dirPath=self.resolveDirPath('psd', self.variant),
            psdNames='["blinks", "skin"]')
        importSdkDataNode = rigrepo.nodes.importDataNode.ImportDataNode(
            'sdk',
            dataFile=self.resolveDataFilePath('sdk.data', self.variant),
            dataType='sdk',
            apply=True)
        importDeformerDataNode = rigrepo.nodes.importDataNode.ImportDataNode(
            'deformerOrder',
            dataFile=self.resolveDataFilePath('deformer_order.data',
                                              self.variant),
            dataType='deformerOrder',
            apply=True)

        skinWtsFileNode = rigrepo.nodes.loadWtsDirNode.LoadWtsDirNode(
            "skinCluster",
            dirPath=self.resolveDirPath('skin_wts', self.variant))

        deltaMushWtsFileNode = rigrepo.nodes.loadWtsDirNode.LoadWtsDirNode(
            "deltaMush",
            dirPath=self.resolveDirPath('deltaMush_wts', self.variant))
        applyNode.addChildren(
            [deformersNode, importDeformerDataNode, importSdkDataNode])
        deformersNode.addChildren([
            skinWtsFileNode, wireWtsFileNode, clusterWtsFileNode,
            importPSDSystemNode, deltaMushWtsFileNode
        ])

        importNodeEditorBookmarsNode = rigrepo.nodes.importNodeEditorBookmarksNode.ImportNodeEditorBookmarksNode(
            "bookmarks",
            dirPath=self.resolveDirPath('bookmarks', self.variant))

        # this will make sure that if the skinCluster is DQ it will support nonRigidScale
        setDqScaleNode = rigrepo.nodes.commandNode.CommandNode('NonRigidScale')
        setDqScaleNodeCmd = '''
import maya.cmds as mc        
for skinCluster in mc.ls(type="skinCluster"):
    mc.setAttr("%s.dqsSupportNonRigid" % skinCluster, 1)
'''
        setDqScaleNode.getAttributeByName("command").setValue(
            setDqScaleNodeCmd)
        skinWtsFileNode.addChild(setDqScaleNode)

        # --------------------------------------------------------------------------------------------------------------
        # Delivery
        # --------------------------------------------------------------------------------------------------------------
        deliveryNode = pubs.pNode.PNode("delivery")
        deliveryNode.disable()
        localizeNode = rigrepo.nodes.commandNode.CommandNode('localize')
        localizeNodeCmd = '''
import rigrepo.libs.skinCluster
import rigrepo.libs.cluster
import maya.cmds as mc

rigrepo.libs.skinCluster.localize(mc.ls(type="skinCluster"), "model")

# localize lid blink clusters
# This is hard coded, may want to take a look at this later.
lidClusters = mc.ls("lid*blink*cluster")
for cluster in lidClusters:
    clusterName = cluster.split("__")[-1]
    rigrepo.libs.cluster.localize(cluster, "{}_auto".format(clusterName), "model")
'''
        localizeNode.getAttributeByName('command').setValue(localizeNodeCmd)

        lockNode = rigrepo.nodes.commandNode.CommandNode('lockNodes')
        lockNodeCmd = '''
import rigrepo.libs.control
import rigrepo.libs.attribute
import maya.cmds as mc

# we shouldn't be locking translates of joints effected by ikHandles
ikJointList = list()
for hdl in mc.ls(type="ikHandle"):
    ikJointList.extend(mc.ikHandle(hdl, q=True, jl=True))
    
controls = rigrepo.libs.control.getControls()
lockNodes = set(mc.ls(type="transform")).difference(controls + [mc.listRelatives(shape, p=True)[0] for shape in mc.ls(type="camera")] + ikJointList)
for node in lockNodes:
    rigrepo.libs.attribute.lock(node, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz','t','r','s'])
    
for ctrl in controls:
    if mc.objExists(ctrl+'.jointOrient'):
        rigrepo.libs.attribute.lock(ctrl, ['jointOrient', 'rotateAxis'])
    
'''
        lockNode.getAttributeByName('command').setValue(lockNodeCmd)

        hideHistoryNode = rigrepo.nodes.commandNode.CommandNode('hideHistory')
        hideHistoryNodeCmd = '''
import maya.cmds as mc    
excludeType = ("skinCluster","wire", "blendShape", "deltaMush", "cluster")
exclude = []
for node in mc.ls("*"):
    if node not in exclude:
        mc.setAttr(node + '.isHistoricallyInteresting', 0)
        if mc.objectType(node) in excludeType:
            mc.setAttr(node + '.isHistoricallyInteresting', 1)
'''
        hideHistoryNode.getAttributeByName('command').setValue(
            hideHistoryNodeCmd)
        deliveryNode.addChildren([localizeNode, lockNode, hideHistoryNode])

        animRigNode.addChildren([
            newSceneNode, loadNode, postBuild, applyNode, deliveryNode,
            importNodeEditorBookmarsNode, frameNode
        ])

        # --------------------------------------------------------------------------------------------------------------
        # Workflow
        # --------------------------------------------------------------------------------------------------------------
        workflowNode = pubs.pNode.PNode('workflow')
        workflowNode.disable()
        self.addNode(workflowNode)

        # --------------------------------------------------------------------------------------------------------------
        # Workflow nodes Un-categorized
        # --------------------------------------------------------------------------------------------------------------

        # Model toggle
        modelToggleNode = rigrepo.nodes.modelOverrideToggleNode.ModelOverrideToggleNode(
            'modelOverride')
        # Rig Pose
        goToRigPoseNode = rigrepo.nodes.goToRigPoseNode.GoToRigPoseNode(
            'goToRigPose')
        workflowNode.addChildren([modelToggleNode, goToRigPoseNode])
        # Gpu Speed Key
        gpuSpeedKey = rigrepo.nodes.gpuSpeedKey.GpuSpeedKeyNode(
            'addGpuKeyframes')
        workflowNode.addChildren(
            [modelToggleNode, goToRigPoseNode, gpuSpeedKey])

        # Shape Authoring
        sculptingNode = pubs.pNode.PNode('sculpting')
        workflowNode.addChildren([sculptingNode])

        duplicateSubdivideNode = rigrepo.nodes.shapeAuthoringNode.ShapeAuthoringNode(
            'subdivide', action='duplicate')
        duplicateSubdivideToggleNode = rigrepo.nodes.shapeAuthoringNode.ShapeAuthoringNode(
            'subdivideToggle', action='toggle')
        duplicateSubdivideCommitNode = rigrepo.nodes.shapeAuthoringNode.ShapeAuthoringNode(
            'subdivideCommit', action='commit')
        extractFacesNode = rigrepo.nodes.shapeAuthoringNode.ShapeAuthoringNode(
            'extractFaces', action='extract')
        extractFacesCommitNode = rigrepo.nodes.shapeAuthoringNode.ShapeAuthoringNode(
            'extractFacesCommit', action='extractCommit')
        sculptingNode.addChildren([
            duplicateSubdivideNode, duplicateSubdivideToggleNode,
            duplicateSubdivideCommitNode, extractFacesNode,
            extractFacesCommitNode
        ])

        # Update Topology
        updateTopologyNode = pubs.pNode.PNode('updateTopology')
        workflowNode.addChildren([updateTopologyNode])

        updateTopologyRenameNode = rigrepo.nodes.updateTopologyNode.UpdateTopologyNode(
            'renameOld', action='rename')
        updateTopologyImportModelNode = rigrepo.nodes.loadFileNode.LoadFileNode(
            "importModel", filePath=self.resolveModelFilePath(self.variant))
        updateTopologyDeformersNode = pubs.pNode.PNode('transferDeformers')
        updateTopologySkinClusterNode = rigrepo.nodes.updateTopologyNode.UpdateTopologyNode(
            'skinCluster', action='skinCluster')
        updateTopologyClusterNode = rigrepo.nodes.updateTopologyNode.UpdateTopologyNode(
            'cluster', action='cluster')
        updateTopologyBlendShapeNode = rigrepo.nodes.updateTopologyNode.UpdateTopologyNode(
            'blendShape', action='blendShape')
        updateTopologyDeformersNode.addChildren([
            updateTopologyBlendShapeNode,
            updateTopologySkinClusterNode,
            updateTopologyClusterNode,
        ])
        updateTopologyReplaceNode = rigrepo.nodes.updateTopologyNode.UpdateTopologyNode(
            'replace', action='replace')

        updateTopologyNode.addChildren([
            updateTopologyRenameNode, updateTopologyImportModelNode,
            updateTopologyDeformersNode, updateTopologyReplaceNode
        ])
        # --------------------------------------------------------------------------------------------------------------
        # Workflow nodes grouped by action
        # --------------------------------------------------------------------------------------------------------------

        # EXPORTERS #
        exporters = pubs.pNode.PNode('exporters')
        # --------------------------------------------------------------------------------------------------------------
        jointExportDataNode = rigrepo.nodes.exportDataNode.ExportDataNode(
            'jointPositions',
            dataFile=self.buildExportPath('joint_positions.data',
                                          self.variant),
            dataType='joint')
        controlOrientsExportDataNode = rigrepo.nodes.exportDataNode.ExportDataNode(
            'controlOrients',
            dataFile=self.buildExportPath('control_orients.data',
                                          self.variant),
            dataType='node')
        controlOrientsExportDataNode.getAttributeByName("Nodes").setValue(
            'mc.ls("*_ort", type="transform")')
        curveExportDataNode = rigrepo.nodes.exportDataNode.ExportDataNode(
            'curvePositions',
            dataFile=self.buildExportPath('curve_positions.data',
                                          self.variant),
            dataType='curve')
        controlCurveExportDataNode = rigrepo.nodes.exportDataNode.ExportDataNode(
            'controlCurvePositions',
            dataFile=self.buildExportPath('control_positions.data',
                                          self.variant),
            dataType='controlCurve')
        sdkExportDataNode = rigrepo.nodes.exportDataNode.ExportDataNode(
            'sdk',
            dataFile=self.buildExportPath('sdk.data', self.variant),
            dataType='sdk')
        deformerOrderExportDataNode = rigrepo.nodes.exportDataNode.ExportDataNode(
            'deformerOrder',
            dataFile=self.buildExportPath('deformer_order.data', self.variant),
            dataType='deformerOrder')
        skinClusterExportWtsNode = rigrepo.nodes.exportWtsDirNode.ExportSkinWtsDirNode(
            'skinCluster',
            dirPath=self.buildExportPath('skin_wts', self.variant))
        wireExportWtsNode = rigrepo.nodes.exportWtsDirNode.ExportWtsDirNode(
            'wire',
            dirPath=self.buildExportPath('wire_wts', self.variant),
            deformerType="wire")
        clusterExportWtsNode = rigrepo.nodes.exportWtsDirNode.ExportWtsDirNode(
            'cluster',
            dirPath=self.buildExportPath('cluster_wts', self.variant),
            deformerType="cluster",
            excludeNodes='mc.ls("lip*",type="cluster")')
        skinClusterExportWtsSelectedNode = rigrepo.nodes.exportWtsSelectedNode.ExportWtsSelectedNode(
            'skinClusterSelected',
            dirPath=self.buildExportPath('skin_wts', self.variant))
        #exportPSDNode = rigrepo.nodes.exportPSDNode.ExportPSDNode('psd',
        #                                                          dirPath=self.buildExportPath('psd', self.variant),
        #                                                          nodesExclude="['clavicle_l_auto_poseInterpolatorShape','clavicle_r_auto_poseInterpolatorShape']",
        #                                                          fileName='skin_psd')
        exportPSDByGroupsNode = rigrepo.nodes.exportPSDNode.ExportPSDByGroupNode(
            'psd',
            dirPath=self.buildExportPath('psd', self.variant),
            groups='rigrepo.libs.psd.getAllGroups()')
        nodeEditorBookmarks = rigrepo.nodes.exportNodeEditorBookmarksNode.ExportNodeEditorBookmarsNode(
            'NodeEditorBookmarks',
            dirPath=self.buildExportPath('bookmarks', self.variant))
        nodeEditorBookmarks.disable()
        # --------------------------------------------------------------------------------------------------------------
        exporters.addChildren([
            controlOrientsExportDataNode, jointExportDataNode,
            curveExportDataNode, controlCurveExportDataNode, sdkExportDataNode,
            skinClusterExportWtsNode, skinClusterExportWtsSelectedNode,
            wireExportWtsNode, clusterExportWtsNode, exportPSDByGroupsNode,
            deformerOrderExportDataNode, nodeEditorBookmarks
        ])

        # Mirroring #
        mirroring = pubs.pNode.PNode('mirror')
        # --------------------------------------------------------------------------------------------------------------
        mirrorControlCurveNode = rigrepo.nodes.mirrorControlCurveNode.MirrorControlCurveNode(
            'controlCurves')
        mirrorWireCurveNode = rigrepo.nodes.mirrorWiresNode.MirrorWiresNode(
            'wireCurves')
        mirrorJointsNode = rigrepo.nodes.mirrorJointsNode.MirrorJointsNode(
            'joints')
        mirrorSkinClusterNode = rigrepo.nodes.mirrorSkinClusterNode.MirrorSkinClusterNode(
            'skinClusterSelected')
        mirrorPSDNode = rigrepo.nodes.mirrorPSDNode.MirrorPSDNode(
            'psdSystems', action='system')
        mirrorOrients = rigrepo.nodes.commandNode.CommandNode('orients')
        mirrorOrientsCmd = '''
import maya.cmds as mc
import rigrepo.libs.transform
rigrepo.libs.transform.mirror (mc.ls(["lip*_l_ort"], type="transform"), search='_l_', replace='_r_', axis="x")
'''
        mirrorOrients.getAttributeByName('command').setValue(mirrorOrientsCmd)
        mirrorSDKNode = rigrepo.nodes.commandNode.CommandNode('sdk')
        mirrorSDKCmd = '''
import maya.cmds as mc
import rigrepo.libs.data.sdk_data as sdk_data
currentData = sdk_data.SdkData()
currentData.gatherDataIterate(mc.ls("*_l_def_auto*", type=["animCurveUU", "animCurveUA", "animCurveUL", "animCurveUT"]))
data = currentData.getData()
for k in data.keys():
    data[k.replace('_l_','_r_')] = data[k]

currentData.applyData(data.keys())
'''
        mirrorSDKNode.getAttributeByName('command').setValue(mirrorSDKCmd)
        #mirrorOrients = rigrepo.nodes.mirrorPSDNode.MirrorPSDNode('psd')
        # --------------------------------------------------------------------------------------------------------------
        mirroring.addChildren([
            mirrorControlCurveNode, mirrorWireCurveNode, mirrorJointsNode,
            mirrorSkinClusterNode, mirrorOrients, mirrorPSDNode, mirrorSDKNode
        ])

        # --------------------------------------------------------------------------------------------------------------
        # Workflow nodes grouped by type
        # --------------------------------------------------------------------------------------------------------------

        # SkinCluster #
        skinClusterNode = pubs.pNode.PNode('skinCluster')
        # --------------------------------------------------------------------------------------------------------------
        yankSkinClusterNode = rigrepo.nodes.yankSkinClusterNode.YankSkinClusterNode(
            'yank')
        sc_mirrorSkinClusterNode = rigrepo.nodes.mirrorSkinClusterNode.MirrorSkinClusterNode(
            'mirror')
        sc_transferSkinClusterNode = rigrepo.nodes.transferDeformer.TransferDeformer(
            'transfer',
            source="body_geo",
            target=["gum_upper_geo"],
            deformerTypes=["skinCluster"],
            surfaceAssociation="closestPoint")
        sc_skinClusterExportWtsNode = copy.deepcopy(skinClusterExportWtsNode)
        sc_skinClusterExportWtsNode.setNiceName('export')
        sc_skinClusterExportSelectedWtsNode = copy.deepcopy(
            skinClusterExportWtsSelectedNode)
        sc_skinClusterExportSelectedWtsNode.setNiceName('exportSel')

        sc_removeLocalizeNode = rigrepo.nodes.commandNode.CommandNode(
            'removeLocalize')
        sc_removeLocalizeCmd = '''
import rigrepo.libs.skinCluster
import rigrepo.libs.cluster
import maya.cmds as mc

rigrepo.libs.skinCluster.removeLocalize(mc.ls(type="skinCluster"))
'''

        sc_removeLocalizeNode.getAttributeByName('command').setValue(
            sc_removeLocalizeCmd)

        # --------------------------------------------------------------------------------------------------------------
        skinClusterNode.addChildren([
            yankSkinClusterNode, sc_mirrorSkinClusterNode,
            sc_skinClusterExportWtsNode, sc_skinClusterExportSelectedWtsNode,
            sc_transferSkinClusterNode, sc_removeLocalizeNode
        ])

        # SDK #
        sdkNode = pubs.pNode.PNode('SDK')
        # --------------------------------------------------------------------------------------------------------------
        sdk_selectNode = rigrepo.nodes.commandNode.CommandNode('selectSDKs')
        sdk_selectCmd = '''
import maya.cmds as mc
mc.select(mc.ls("*_def_auto*", type=["animCurveUU", "animCurveUA", "animCurveUL", "animCurveUT"]))
        '''
        sdk_selectNode.getAttributeByName('command').setValue(sdk_selectCmd)
        sdk_mirrorNode = rigrepo.nodes.commandNode.CommandNode('mirror')
        sdk_mirrorNode.getAttributeByName('command').setValue(mirrorSDKCmd)
        sdk_exportNode = copy.deepcopy(sdkExportDataNode)
        sdk_exportNode.setNiceName('export')
        # --------------------------------------------------------------------------------------------------------------
        sdkNode.addChildren([sdk_selectNode, sdk_mirrorNode, sdk_exportNode])

        # --------------------------------------------------------------------------------------------------------------
        # PSD
        # --------------------------------------------------------------------------------------------------------------
        psdNode = pubs.pNode.PNode('psd')

        # --------------------------------------------------------------------------------------------------------------
        addPosePSDNode = rigrepo.nodes.addPosePSDNode.AddPosePSDNode('addPose')
        addUpdatePSDNode = rigrepo.nodes.addPosePSDNode.AddPosePSDNode(
            'updatePose', action='updatePose')
        psd_mirrorPSDNodes = rigrepo.nodes.mirrorPSDNode.MirrorPSDNode(
            'mirrorSystem', action='system')
        psd_mirrorPSDDeltaNode = rigrepo.nodes.mirrorPSDNode.MirrorPSDNode(
            'mirrorDeltas', action='deltas')
        psd_deletePSDDeltaNode = rigrepo.nodes.addPosePSDNode.AddPosePSDNode(
            'deleteDeltas', action='deleteDeltas')
        psd_exportPSDNode = copy.deepcopy(exportPSDByGroupsNode)
        psd_exportPSDNode.setNiceName('export')
        # --------------------------------------------------------------------------------------------------------------
        psdNode.addChildren([
            addPosePSDNode, addUpdatePSDNode, psd_mirrorPSDNodes,
            psd_mirrorPSDDeltaNode, psd_deletePSDDeltaNode, psd_exportPSDNode
        ])

        # joints
        jointsNode = pubs.pNode.PNode('joints')
        zeroJointsNode = rigrepo.nodes.zeroJointsNode.ZeroJointsNode(
            'zeroJoints')
        jnt_mirrorJointsNode = copy.deepcopy(mirrorJointsNode)
        jnt_mirrorJointsNode.setNiceName('mirror')
        jnt_jointExportDataNode = copy.deepcopy(jointExportDataNode)
        jnt_jointExportDataNode.setNiceName('export')
        jointsNode.addChildren(
            [zeroJointsNode, jnt_mirrorJointsNode, jnt_jointExportDataNode])

        # anim
        animNode = pubs.pNode.PNode('anim')
        animTestsNode = pubs.pNode.PNode('tests')
        animTestDanceFlip2Node = rigrepo.nodes.commandNode.CommandNode(
            'danceFlip2')
        animNode.addChildren([animTestsNode])
        animTestsNode.addChildren([animTestDanceFlip2Node])

        animTestDanceFlip2NodeCMD = '''
import maya.cmds as mc
import rigrepo.tests as tests
import os 
import maya.mel as mm

if not mc.pluginInfo('atomImportExport', q=1, l=1):  
    mc.loadPlugin('atomImportExport')

testPath = os.path.dirname(tests.__file__).replace("\\\\", "/")
fileName = testPath + "/animation/dance_flip_2.atom"

mm.eval("select -r ac_lf_toe ac_lf_footFK ac_rt_toe ac_rt_footFK ac_rt_kneeFK ac_lf_kneeFK ac_lf_hipFK ac_rt_hipFK ac_lf_handFK ac_lf_elbowFK ac_lf_armFK ac_rt_handFK ac_rt_elbowFK ac_rt_armFK ac_rt_shoulder ac_lf_shoulder ac_cn_neck ac_cn_head ac_cn_root ac_cn_chest ac_rt_leg_settings ac_lf_leg_settings")
mm.eval("file -import -type \\"atomImport\\" -ra true -namespace \\"dance_flip_2\\" -options \\";;targetTime=1;srcTime=0.8:194.4;dstTime=0.8:194.4;option=scaleInsert;match=hierarchy;;selected=selectedOnly;search=;replace=;prefix=;suffix=;mapFile=;\\" \\""+fileName+"\\";")
'''
        animTestDanceFlip2Node.getAttributeByName('command').setValue(
            animTestDanceFlip2NodeCMD)

        # add all of the nodes in order to the workflow node.
        workflowNode.addChildren([
            exporters, mirroring, skinClusterNode, psdNode, sdkNode,
            jointsNode, animNode
        ])