def installProc(self, characterName, *args):
        # Return the directory names from setupDirs
        projectDirs = turbineUtils.setupDirs(self.characterName, create=False)       
        setupDir = projectDirs[1]
        xmlDir = projectDirs[2]
        rigDir = projectDirs[3]
        characterFileName = projectDirs[5]   
        setupFileName = projectDirs[6]        
        xmlFileName = projectDirs[7]
        meshDir = projectDirs[8]
        characterName = self.characterName
      
        """ use turbineUtils to find out the namespaces. """
        namespaces = turbineUtils.getCharacterNamespace(self.characterName)    
        characterNamespace = namespaces[0]        
        characterNameString = (characterNamespace + ":")
       
        """ Import the rig """
        # Return the directory names from setupDirs
        projectDirs = turbineUtils.setupDirs(self.characterName, create=False) 
        characterFileName = projectDirs[5]

        if cmds.namespace(exists=characterNamespace):
            print "Rig Installed"
        else:
            cmds.file(characterFileName, i=True, namespace=characterNamespace)
            cmds.namespace(set=characterNamespace)   
            
        cmds.namespace(setNamespace=":")  

        """ Unlock the character container """
        characterContainer = (characterNamespace + ":character_container")
        cmds.lockNode(characterContainer, lock=False, lockUnpublished=False)
        
        setupContainer = self.setupGameJoints(characterName, namespaces)

        """ Import the mesh if it exists """
        self.setupMesh(characterName, setupContainer)
        
        
        """ Lock the containers """
        cmds.lockNode(characterContainer, lock=True, lockUnpublished=True)
        cmds.lockNode(setupContainer, lock=True, lockUnpublished=True)
        
        """ Set namespace back to default """
        cmds.namespace(set=":")

        cmds.deleteUI(self.UIElements["window"])
        
                    
        """ Create all the necessary character directories if they do not exist """  
        import System.directoryExtension as directoryExtension
        dirExt = directoryExtension.DirectoryExtension()  
        dirExt.createAllDirs()
        dirExt.createBakDirs()
        
        """ Get the user name and inform of operation completion """       
        currentUser = getUser()        
        niceName = (currentUser)[1]
        cmds.headsUpMessage(self.characterName+ " has been installed " + niceName)
Beispiel #2
0
    def installProc(self, characterName, *args):
        # Return the directory names from setupDirs
        projectDirs = turbineUtils.setupDirs(self.characterName, create=False)
        setupDir = projectDirs[1]
        xmlDir = projectDirs[2]
        rigDir = projectDirs[3]
        characterFileName = projectDirs[5]
        setupFileName = projectDirs[6]
        xmlFileName = projectDirs[7]
        meshDir = projectDirs[8]
        characterName = self.characterName
        """ use turbineUtils to find out the namespaces. """
        namespaces = turbineUtils.getCharacterNamespace(self.characterName)
        characterNamespace = namespaces[0]
        characterNameString = (characterNamespace + ":")
        """ Import the rig """
        # Return the directory names from setupDirs
        projectDirs = turbineUtils.setupDirs(self.characterName, create=False)
        characterFileName = projectDirs[5]

        if cmds.namespace(exists=characterNamespace):
            print "Rig Installed"
        else:
            cmds.file(characterFileName, i=True, namespace=characterNamespace)
            cmds.namespace(set=characterNamespace)

        cmds.namespace(setNamespace=":")
        """ Unlock the character container """
        characterContainer = (characterNamespace + ":character_container")
        cmds.lockNode(characterContainer, lock=False, lockUnpublished=False)

        setupContainer = self.setupGameJoints(characterName, namespaces)
        """ Import the mesh if it exists """
        self.setupMesh(characterName, setupContainer)
        """ Lock the containers """
        cmds.lockNode(characterContainer, lock=True, lockUnpublished=True)
        cmds.lockNode(setupContainer, lock=True, lockUnpublished=True)
        """ Set namespace back to default """
        cmds.namespace(set=":")

        cmds.deleteUI(self.UIElements["window"])
        """ Create all the necessary character directories if they do not exist """
        import System.directoryExtension as directoryExtension
        dirExt = directoryExtension.DirectoryExtension()
        dirExt.createAllDirs()
        dirExt.createBakDirs()
        """ Get the user name and inform of operation completion """
        currentUser = getUser()
        niceName = (currentUser)[1]
        cmds.headsUpMessage(self.characterName + " has been installed " +
                            niceName)
Beispiel #3
0
    def loadSkinWeights(self, *args):
        import maya.mel as mel
        #import tsapi.core.maya.animation as annie
        #reload(annie)

        try:
            character = cmds.ls(sl=True)[0]
        except:
            cmds.headsUpMessage("Please Select Valid Geometry")
            return

        # Define the file name and path
        characterName = self.characterName
        skinPath = turbineUtils.setupDirs(characterName, create=False)[4]
        outFileSuffix = '_skinWeight.csv'
        outFile = (character + outFileSuffix)
        finalPath = (skinPath + outFile)

        missingJoints = []
        allCV = []
        if cmds.file(finalPath, q=True, ex=True):
            reader = csv.reader(open(finalPath, 'rb'),
                                delimiter=' ',
                                quotechar='|')
        else:
            return

        # Find the skin cluster
        selection = cmds.ls(sl=True, fl=True)
        mel.eval("$selectionList = `ls -sl`")
        skCl = mel.eval('findRelatedSkinCluster $selectionList[0]')

        for row in reader:
            if row not in allCV:
                allCV.append(row)

        for cv in allCV:
            splitString1 = cv[0].partition(",")
            vert = splitString1[0]
            splitString2 = splitString1[2].partition(",")
            joint = splitString2[0]
            value = float(splitString2[2])

            if cmds.objExists(joint):
                cmds.skinPercent(skCl, vert, transformValue=[(joint, value)])
            else:
                missingJoints.append(joint)
        """ Normalize the weights """
        cmds.skinPercent(skCl, normalize=True)

        if len(missingJoints) == 0:
            cmds.headsUpMessage("The weight has been loaded from " + finalPath)
        else:
            cmds.headsUpMessage(
                "Influences are missing.  Please view the script editor for details."
            )
            print "These influences do not exist"
            for joint in missingJoints:
                print joint
Beispiel #4
0
    def loadSkinWeights(self, *args):
        import maya.mel as mel
        
        try:
            character = cmds.ls(sl=True)[0]
        except:
            cmds.headsUpMessage("Please Select Valid Geometry")
            return

        
        # Define the file name and path
        characterName = self.characterName
        skinPath = turbineUtils.setupDirs(characterName, create=False)[4]
        outFileSuffix = '_skinWeight.csv'
        outFile = (character + outFileSuffix )
        finalPath = (skinPath + outFile)

        missingJoints = []
        allCV = []
        if cmds.file(finalPath, q=True, ex=True):
            reader = csv.reader(open(finalPath, 'rb'), delimiter=' ', quotechar='|')
        else:
            return
        
        # Find the skin cluster
        selection= cmds.ls(sl=True, fl=True)
        mel.eval("$selectionList = `ls -sl`")
        skCl = mel.eval('findRelatedSkinCluster $selectionList[0]')
    
        for row in reader:
            if row not in allCV:
                allCV.append(row)
                
        for cv in allCV:
            splitString1 = cv[0].partition(",")
            vert =  splitString1[0]
            splitString2 = splitString1[2].partition(",")
            joint = splitString2[0]
            value = float(splitString2[2])
        
            
            if cmds.objExists(joint):
                cmds.skinPercent( skCl, vert, transformValue=[(joint, value)])
            else:
                missingJoints.append(joint)
                
        """ Normalize the weights """
        cmds.skinPercent(skCl, normalize=True)
        
        if len(missingJoints) == 0:  
            cmds.headsUpMessage("The weight has been loaded from " + finalPath)
        else:
            cmds.headsUpMessage("Influences are missing.  Please view the script editor for details.")
            print "These influences do not exist"
            for joint in missingJoints:
                print joint
Beispiel #5
0
    def setupMesh(self, characterName, setupContainer):
        projectDirs = turbineUtils.setupDirs(self.characterName, create=False)
        meshDir = projectDirs[8]
        characterName = self.characterName
        #setupContainer = self.setupContainer
        """ Import the mesh if it exists """
        meshName = (meshDir + characterName + ".ma")

        geoGrp = "Geometry"
        if cmds.file(meshName, q=True, ex=True):
            """ Create a group for the mesh """
            cmds.file(meshName, i=True, gr=True, gn=geoGrp)
            cmds.select(geoGrp)
            """ Add an attribute to the geo group that toggles vis mode. """
            enumNames = "normal:template:reference"
            try:
                cmds.setAttr("Geometry.overrideEnabled", 1)
                cmds.container(setupNode,
                               edit=True,
                               publishAndBind=[
                                   "Geometry.overrideDisplayType", "GeoDisplay"
                               ])
            except:
                print 'attribute exists'
        else:
            print "mesh does not exist on disk"
        """ Get the mesh into a var """
        if cmds.objExists(geoGrp):
            characterGeo = cmds.listRelatives(geoGrp, c=True, type="transform")
            """ Parent the geo to the geo grp """
            #for geo in characterGeo:
            #cmds.parent(geo, geoGrp)
            """ Unlock the setup container """
            cmds.lockNode(setupContainer, lock=False, lockUnpublished=False)
            """ Add the Geo grp to the setup container """
            cmds.container(setupContainer,
                           edit=True,
                           addNode=geoGrp,
                           inc=True,
                           ihb=True,
                           isd=True,
                           includeNetwork=True,
                           force=True)

            import System.skinning as skinning
            """ Skin the mesh """
            cmds.select(characterGeo)
            doSkin = skinning.skinning_Tools()
            doSkin.attachWithSkinning()
            """ Apply skin weights if they exist """
            cmds.select(characterGeo)
            doSkin.loadSkinWeights(characterName)
Beispiel #6
0
    def saveSkinWeights(self, *args):
        ''' This next block is used to define the path where the weights will be saved.
        I plan on putting this in the __init__ once I am done testing '''
        print "saving weights"
        
        try:
            character = cmds.ls(sl=True)[0]
        except:
            cmds.headsUpMessage("Please Select Valid Geometry")
            return
        weights = animation.Weights()
        

        # Define the file name and path
        characterName = self.characterName 
        skinPath = turbineUtils.setupDirs(characterName, create=False)[4]
        outFileSuffix = '_skinWeight.csv'
        outFile = (character + outFileSuffix )
        finalPath = (skinPath + outFile)
        
        """ Delete the skin file if one already exists """
        if cmds.file(finalPath, q=True, ex=True):
            os.remove(finalPath)
                
        # Select the character here, then use GetValidSkinWeights to grab vert info.

        for char in Weights.getValidSkinWeights():
            vert = char[0]
        
            jointInfo = char[1]
            for each in jointInfo:
                joint = each[0]
                tmpWeight = each[1]

                weight = str("%.2f" % tmpWeight)
                weight = float(weight)

                value = (vert, joint, weight)
                   
                writer = csv.writer(open(finalPath, "a"))                
                writer.writerow(value)
        """ I need to make sure the file closes here """            
        # Close the file
        #file.close(finalPath)
        
         # Get the user name and inform the user the weights have been saved        
        currentUser = getUser()        
        niceName = (currentUser)[1]
        cmds.headsUpMessage("The weight file has been saved to " + finalPath)
Beispiel #7
0
    def saveSkinWeights(self, *args):
        ''' This next block is used to define the path where the weights will be saved.
        I plan on putting this in the __init__ once I am done testing '''
        print "saving weights"
        #import tsapi.core.maya.animation as annie
        #reload(annie)

        try:
            character = cmds.ls(sl=True)[0]
        except:
            cmds.headsUpMessage("Please Select Valid Geometry")
            return
        annie = annie.animation()

        # Define the file name and path
        characterName = self.characterName
        skinPath = turbineUtils.setupDirs(characterName, create=False)[4]
        outFileSuffix = '_skinWeight.csv'
        outFile = (character + outFileSuffix)
        finalPath = (skinPath + outFile)
        """ Delete the skin file if one already exists """
        if cmds.file(finalPath, q=True, ex=True):
            os.remove(finalPath)

        # Select the character here, then use GetValidSkinWeights to grab vert info.
        print " Annie used here"
        for char in annie.GetValidSkinWeights():
            vert = char[0]

            jointInfo = char[1]
            for each in jointInfo:
                joint = each[0]
                tmpWeight = each[1]

                weight = str("%.2f" % tmpWeight)
                weight = float(weight)

                value = (vert, joint, weight)

                writer = csv.writer(open(finalPath, "a"))
                writer.writerow(value)
        """ I need to make sure the file closes here """
        # Close the file
        #file.close(finalPath)

        # Get the user name and inform the user the weights have been saved
        currentUser = getUser()
        niceName = (currentUser)[1]
        cmds.headsUpMessage("The weight file has been saved to " + finalPath)
    def setupMesh(self, characterName, setupContainer):
        projectDirs = turbineUtils.setupDirs(self.characterName, create=False)
        meshDir = projectDirs[8]
        characterName = self.characterName
        #setupContainer = self.setupContainer
          
        """ Import the mesh if it exists """
        meshName = (meshDir + characterName + ".ma")
        
        geoGrp = "Geometry"
        if cmds.file(meshName, q=True, ex=True):
            """ Create a group for the mesh """
            cmds.file(meshName, i=True, gr=True, gn=geoGrp)
            cmds.select(geoGrp)
            """ Add an attribute to the geo group that toggles vis mode. """
            enumNames = "normal:template:reference"
            try:
                cmds.setAttr("Geometry.overrideEnabled", 1)
                cmds.container(setupNode, edit=True, publishAndBind=["Geometry.overrideDisplayType", "GeoDisplay"]) 
            except: print 'attribute exists'
        else:
            print "mesh does not exist on disk"
         
        """ Get the mesh into a var """
        if cmds.objExists(geoGrp):
            characterGeo = cmds.listRelatives(geoGrp, c=True, type="transform")

            """ Parent the geo to the geo grp """
            #for geo in characterGeo:
                #cmds.parent(geo, geoGrp) 
                
            """ Unlock the setup container """
            cmds.lockNode(setupContainer, lock=False, lockUnpublished=False)
            
            """ Add the Geo grp to the setup container """
            cmds.container(setupContainer, edit=True, addNode=geoGrp, inc=True, ihb=True, isd=True, includeNetwork=True, force=True)
            
        
            import System.skinning as skinning
            """ Skin the mesh """
            cmds.select(characterGeo)
            doSkin = skinning.skinning_Tools()
            doSkin.attachWithSkinning()
                    
            """ Apply skin weights if they exist """
            cmds.select(characterGeo)
            doSkin.loadSkinWeights(characterName)
    def installProc(self, characterName, *args):

        # Return the directory names from setupDirs
        projectDirs = turbineUtils.setupDirs(self,
                                             self.characterName,
                                             create=False)
        setupDir = projectDirs[1]
        xmlDir = projectDirs[2]
        rigDir = projectDirs[3]
        characterFileName = projectDirs[5]
        setupFileName = projectDirs[6]
        xmlFileName = projectDirs[7]

        # use turbineUtils to find out the namespaces.
        namespaces = turbineUtils.getCharacterNamespace(
            self, self.characterName)

        characterNamespace = namespaces[0]
        exportNamespace = namespaces[1]
        try:
            cmds.namespace(add=exportNamespace)
        except:
            pass

        characterNameString = (characterNamespace + ":")

        # Import the rig
        # Return the directory names from setupDirs
        projectDirs = turbineUtils.setupDirs(self,
                                             self.characterName,
                                             create=False)
        characterFileName = projectDirs[5]
        print characterFileName
        if cmds.namespace(exists=characterNamespace):
            print "Rig Installed"
        else:
            cmds.file(characterFileName, i=True, namespace=characterNamespace)

        cmds.namespace(setNamespace=":")

        # Unlock
        characterContainer = (characterNamespace + ":character_container")
        cmds.lockNode(characterContainer, lock=False, lockUnpublished=False)
        """ Check to see if a setup file already exists."""
        """If a setup exists, delete it."""
        setupContainer = exportNamespace + ":Setup"
        if cmds.objExists(setupContainer):
            cmds.select(setupContainer)
            cmds.lockNode(lock=False, lu=False)
            cmds.delete(setupContainer)

        # Import the setup
        # If the setup file exists on disk, import it.  Else we should build the setup
        if cmds.file(setupFileName, q=True, ex=True):
            cmds.file(setupFileName, i=True)
            cmds.setAttr("Setup_grp.visibility", 0)
            constraints = utils.parentToBlueprint(xmlFileName,
                                                  characterNameString)
            parentConstraints = constraints[0]
            scaleConstraints = constraints[1]
            """ Create the setup container if it does not exist """
            try:
                cmds.container(n=setupContainer)
            except:
                pass
            """ Add the setup and geometry groups to the setup container """
            cmds.container(setupContainer,
                           edit=True,
                           addNode="Setup_grp",
                           ihb=True,
                           force=True)
            try:
                cmds.container(setupContainer,
                               edit=True,
                               addNode="Geometry",
                               ihb=True,
                               force=True)
            except:
                pass
            """ Add the game_joint_parentConstraints to the Setup container """
            for constraint in parentConstraints:
                cmds.container(setupContainer,
                               edit=True,
                               addNode=constraint,
                               ihb=True,
                               force=True)
            for constraint in scaleConstraints:
                cmds.container(setupContainer,
                               edit=True,
                               addNode=constraint,
                               ihb=True,
                               force=True)

        else:
            cmds.group(n="Setup_grp", empty=True)
            cmds.setAttr("Setup_grp.visibility", 0)
            try:
                cmds.namespace(add=exportNamespace)
            except:
                pass
            newSetupName = (exportNamespace + ":" + "Setup")

            cmds.select("Setup_grp")
            setupContents = cmds.listConnections("Setup_grp", type="joint")

            if setupContents != None and "game_joints" in (setupContents):
                constraints = utils.parentToBlueprint(xmlFileName,
                                                      characterNameString)
                parentConstraints = constraints[0]
                scaleConstraints = constraints[1]
                """ Add the game_joint_parentConstraints to the Setup container """
                for constraint in parentConstraints:
                    cmds.container(setupContainer,
                                   edit=True,
                                   addNode=constraint,
                                   ihb=True,
                                   force=True)
                for constraint in scaleConstraints:
                    cmds.container(setupContainer,
                                   edit=True,
                                   addNode=constraint,
                                   ihb=True,
                                   force=True)

            else:
                #Create the game joints and return the joint names
                cmds.select("Setup_grp")
                utilInfo = utils.importJointInfo(xmlFileName)
                listJoints = utilInfo

                # parent the joints into the setup group
                cmds.parent(listJoints, "Setup_grp")

                setupContainer = cmds.container(n="Setup",
                                                addNode="Setup_grp",
                                                inc=True,
                                                ihb=True,
                                                includeNetwork=True,
                                                force=True)

                utils.setJointAttrs(xmlFileName)
                constraints = utils.parentToBlueprint(xmlFileName,
                                                      characterNameString)
                parentConstraints = constraints[0]
                scaleConstraints = constraints[1]
                """ Add the game_joint_parentConstraints to the Setup container """
                for constraint in parentConstraints:
                    cmds.container(setupContainer,
                                   edit=True,
                                   addNode=constraint,
                                   ihb=True,
                                   force=True)
                for constraint in scaleConstraints:
                    cmds.container(setupContainer,
                                   edit=True,
                                   addNode=constraint,
                                   ihb=True,
                                   force=True)

                try:
                    cmds.namespace(add=exportNamespace)
                except:
                    pass

                newSetupName = (exportNamespace + ":" + "Setup")
                cmds.rename("Setup", newSetupName)

        newSetupName = (exportNamespace + ":" + "Setup")

        # Use turbineUtils to set bone marking and holding locations.
        turbineUtils.boneMarking()
        holdLocs = turbineUtils.loadHoldLocs()

        # add holding locs to the setup container
        cmds.container(newSetupName,
                       edit=True,
                       addNode=holdLocs,
                       inc=True,
                       ihb=True,
                       includeNetwork=True,
                       force=True)

        cmds.namespace(set=":")

        cmds.lockNode(characterContainer, lock=True, lockUnpublished=True)
        cmds.lockNode(newSetupName, lock=True, lockUnpublished=True)
        cmds.deleteUI(self.UIElements["window"])

        currentUser = getUser()

        niceName = (currentUser)[1]
        cmds.headsUpMessage(self.characterName + " has been installed " +
                            niceName)

        return (characterContainer, newSetupName)
Beispiel #10
0
    def loadHoldLocs(self, *args):
        import xml.dom.minidom
        import xml.dom

        characterName = ""
        xmlDir = turbineUtils.setupDirs(characterName, create=False)[2]
        # The name of the holding location
        allLocs=[]
        allJoints=[]

        bindJoints = self.jointUtils.getGameJoints()
        
        if bindJoints == None:
            cmds.headsUpMessage( 'No game joints exist in this scene.  Holding locations will not be added.')
            return
        else:
            # We should create a holding loc for each game joint.    
            cmds.select( clear=True )
    
            # open the xml file for reading 
            holdLocFile = (xmlDir + "/holdLocList.xml")
    
            fileObject = file(holdLocFile, 'r')
           
            # parse the xml file to get all of it's elements
            xmlDoc = xml.dom.minidom.parse(fileObject)
            # Get the joint elements into a list
            joints = xmlDoc.getElementsByTagName('joint')
            # iterate through all of the joint elements
            #Loads joint positions
            for joint in joints:
                # get the child elements of the joint in order to get the loc name
                children = joint.childNodes            
                # loop through the child elements
                for child in children:
                    # make sure the the current node type is not a text node
                    if child.nodeType != child.TEXT_NODE:
                    
                    # Deal with holding loc name. #########################################################
                        if child.tagName == "locName":
                            # if the node is locName node get it's children
                            # to get the locName
                            locAxis = child.childNodes
                            for axis in locAxis:
                                if axis.nodeType != axis.TEXT_NODE:
                                    locValue = axis.getAttribute("value")
    
                                    
                # get the name of the joint from the name attribute attached to the joint element.
                jointName = joint.getAttribute("name")                                 
    
                if cmds.objExists(jointName):     
                    allJoints.append(jointName)
                    jointPos = cmds.xform(jointName, q=True, ws=True, t=True, a=True)
                    # Final name for the holding location 
                                                            
                    locName = ("HoldingLocation_" + jointName + "_" + locValue)
            
                    allLocs.append(locName)
                    
                    if cmds.objExists(locName) == False:
    
                        locGrp = pm.group(em=True, w=True, n=locName)
        
                        locGrp = cmds.ls(sl=True)
                        locGrp = (locGrp)[0]
        
                        # Move locGrp to joints position
                        cmds.move(jointPos[0], jointPos[1], jointPos[2], locGrp, r=True)
                        
                        cmds.setAttr(locGrp + '.displayHandle', 1)
                        cmds.setAttr(locGrp + '.displayLocalAxis', 1)
    
                        # Add an "LocationType" attr to the holding loc
                        cmds.addAttr(ln="LocationType", dt="string", k=False)
                        cmds.setAttr(locGrp+".LocationType", locValue, type="string")
                        # parent the holdLoc to the joint
                        cmds.parent(locGrp, jointName)

                  
            # close the file
            fileObject.close()
            
        # Return some info to let the user know if the holding locs were created.
        jntLen = len(allJoints)
        locLen = len(allLocs)
    
        return allLocs
Beispiel #11
0
    def saveSetup(self, *args):
        exportNodes = []

        # Query the text field from the saveSetupUI to see if the user chose a new name.
        setupName = cmds.textField(self.SaveTemplateUIElements["nameField"],
                                   q=True,
                                   text=True)

        characterName = self.characterName
        tmpDir = turbineUtils.setupDirs(characterName, create=False)[0]
        characterDir = (tmpDir + "\export\\")

        # Find the setup node.
        fullCharName = self.fullCharName
        exportName = fullCharName.replace("Character__", "Export__")

        setupNode = (exportName + ":Setup")

        cmds.lockNode(setupNode, lock=False, lockUnpublished=False)
        #tmpSetupNode = cmds.rename(setupNode, "Setup")
        # Define the path and name for the setup file.
        #setupFileName = characterDir + setupName + "_setup" + ".ma"
        setupFileName = characterDir + setupName + ".ma"
        cmds.select(cl=True)

        #gameJntConnections = cmds.container(tmpSetupNode,query=True,nodeList=True)
        gameJntConnections = cmds.container(setupNode,
                                            query=True,
                                            nodeList=True)

        # Remove the setup_grp and geometry group from it's container.
        cmds.container(setupNode, edit=True, removeNode="Setup_grp", ihb=True)
        if cmds.objExists("Geometry"):
            cmds.container(setupNode,
                           edit=True,
                           removeNode="Geometry",
                           ihb=True)
            cmds.select("Geometry")
        cmds.select("Setup_grp", add=True)

        # ad some stuff here to query and remove from namespaces

        cmds.file(setupFileName,
                  exportSelected=True,
                  con=False,
                  type="mayaAscii")

        # Put the setup and geo groups back in the container.
        cmds.container(setupNode,
                       edit=True,
                       addNode="Setup_grp",
                       ihb=True,
                       force=True)
        if cmds.objExists("Geometry"):
            cmds.container(setupNode,
                           edit=True,
                           addNode="Geometry",
                           ihb=True,
                           force=True)

        # Confirm that the setup has been exported
        exportConfirm = (setupName + " has been exported to " + characterDir)
        cmds.confirmDialog(messageAlign="center",
                           title="Create Directory",
                           message=exportConfirm)

        cmds.lockNode(setupNode, lock=True, lockUnpublished=True)

        cmds.select(cl=True)
Beispiel #12
0
    def setupInstallProc(self, characterName):
        # Return the directory names from setupDirs
        projectDirs = turbineUtils.setupDirs(characterName, create=False)
        setupDir = projectDirs[1]
        xmlDir = projectDirs[2]
        rigDir = projectDirs[3]
        characterFileName = projectDirs[5]
        xmlFileName = projectDirs[7]

        selItem = cmds.textScrollList(
            self.SaveTemplateUIElements["characterList"], q=True, si=True)

        setupFileName = (setupDir + selItem[0] + ".ma")

        # use turbineUtils to find out the namespaces.
        fullCharName = turbineUtils.getCharacterInfo()[2]

        characterNamespace = fullCharName
        exportNamespace = fullCharName.replace("Character", "Export")

        try:
            cmds.namespace(add=exportNamespace)
        except:
            pass

        characterNameString = (characterNamespace + ":")

        # Unlock
        characterContainer = (characterNamespace + ":character_container")
        cmds.lockNode(characterContainer, lock=False, lockUnpublished=False)
        """ Check to see if a setup container already exists."""
        """If a setup_grp exists, delete it."""

        setupContainer = turbineUtils.getCharacterInfo()[3]

        # Delete the contents of the setup container
        if cmds.objExists(setupContainer):
            cmds.select(setupContainer)
            cmds.lockNode(lock=False, lu=False)
            setupNodes = cmds.container(setupContainer, q=True, nl=True)
            cmds.delete(setupNodes)

        # Import the setup
        # If the setup file exists on disk, import it.  Else we should build the setup
        if cmds.file(setupFileName, q=True, ex=True):
            cmds.file(setupFileName, i=True)
            #Setup_grp vis to 0
            cmds.setAttr("Setup_grp.visibility", 0)
            """ Create the setup container if it does not exist """
            if cmds.objExists(setupContainer):
                pass
            else:
                cmds.container(n=setupContainer)
        """ Add the setup and geometry groups to the setup container """
        cmds.container(setupContainer,
                       edit=True,
                       addNode="Setup_grp",
                       ihb=True,
                       force=True)
        try:
            cmds.container(setupContainer,
                           edit=True,
                           addNode="Geometry",
                           ihb=True,
                           force=True)
        except:
            pass

        constraints = turbineUtils.parentToBlueprint(xmlFileName,
                                                     characterNameString)
        parentConstraints = constraints[0]
        scaleConstraints = constraints[1]
        """ Add the game_joint_parentConstraints to the Setup container """
        for constraint in parentConstraints:
            cmds.container(setupContainer,
                           edit=True,
                           addNode=constraint,
                           ihb=True,
                           force=True)
        for constraint in scaleConstraints:
            cmds.container(setupContainer,
                           edit=True,
                           addNode=constraint,
                           ihb=True,
                           force=True)

        # Use turbineUtils to set bone marking and holding locations.
        turbineUtils.boneMarking()

        holdLocs = turbineUtils.loadHoldLocs()

        # add holding locs to the setup container
        cmds.container(setupContainer,
                       edit=True,
                       addNode=holdLocs,
                       inc=True,
                       ihb=True,
                       includeNetwork=True,
                       force=True)

        cmds.namespace(set=":")

        cmds.lockNode(characterContainer, lock=True, lockUnpublished=True)
        cmds.lockNode(setupContainer, lock=True, lockUnpublished=True)
        cmds.deleteUI(self.SaveTemplateUIElements["window"])

        # Get the user name and inform the user
        currentUser = getUser()
        niceName = (currentUser)[1]
        cmds.headsUpMessage(self.characterName + " has been installed " +
                            niceName)

        return (characterContainer, setupContainer)