def __init__(self, *args):
      import System.directoryExtension as dirExt
      reload(dirExt)
      dirExt = dirExt.DirectoryExtension()
      self.animDir = dirExt.paths['animLib']
      
      """
      TODO:
          MOVE ALL FILE FINDING UTILS INTO A CLASS
      """
      """ Find all the valid rigs and store them in a dictionary """
      self.rigFiles = {}
      self.rigs = {}
      
      refUtils = referenceUtils.Reference_Utils()
 
      self.rigFiles['rigFiles'] = refUtils.findRigs()[0]
      self.rigs['rigs'] = refUtils.findRigs()[1]
      
      self.currentRefs = {}
      
      """ Call animationModuleSettings """
      self.animMods = animModSettings.AnimMod_Info()
 
      """ Find all the files in the animation lib directory """
      """ Using this to switch art path for now """
      """ Define the artPath """
      import System.directoryExtension as directoryExtension
      dirExt = directoryExtension.DirectoryExtension()
      self.artPath = dirExt.artPath
      
      self.fileDirectory = (self.artPath + 'character/GEPPETTO/Animation/animLib/')
      self.currentDirectory = {}
      self.currentDirectory['newDirectory'] = self.fileDirectory
      self.anims = os.listdir(self.fileDirectory)
      
      """ Get the name of the animation file to use as a starting point for naming the output from animLib """
      self.sceneName = self.getSceneName()        
      
      """ The UI """
      """ Store the UI elements in a dictionary """
      self.UIElements = {}
      
      """ Create a dictionary to store the character name
      Run a function to get character name """
      self.characterInfo = {}
      
      UIInit = self.initializeInitVars()
      if UIInit == False:
          return
      else:
          self.animLibUI()
Example #2
0
    def storeJointVars(self, gameJointNames, parentJointNames, jointPositionX,
                       jointPositionY, jointPositionZ, jointRotateOrder,
                       blueprintJointNames, jointOrientX, jointOrientY,
                       jointOrientZ, containerName):
        # Define the file name and path
        userName = userUtils.getUser()[0]
        outFileSuffix = '_gameJntInfo.csv'
        outFile = (userName + outFileSuffix)
        """ Define the artPath """
        import System.directoryExtension as directoryExtension
        dirExt = directoryExtension.DirectoryExtension()
        artPath = dirExt.artPath

        filePath = artPath + "/character/GEPPETTO/Data/"

        finalPath = (filePath + outFile)

        for index in range(len(gameJointNames)):
            int = str(index)

            value = (gameJointNames[index], parentJointNames[index],
                     jointPositionX[index], jointPositionY[index],
                     jointPositionZ[index], jointRotateOrder[index],
                     blueprintJointNames[index], jointOrientX[index],
                     jointOrientY[index], jointOrientZ[index])

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

        cmds.headsUpMessage("The temp data file has been saved to " +
                            finalPath)
Example #3
0
def findAllFiles(relativeDirectory, fileExtension):
    """ Using this to switch art path for now """
    """ Define the artPath """
    import System.directoryExtension as directoryExtension
    dirExt = directoryExtension.DirectoryExtension()
    artPath = dirExt.artPath

    rigDir = artPath + "character/"

    # Search the relative directory for all files with the given extension.
    # Return a list of all file names, excluding the file extension

    fileDirectory = rigDir + "/" + relativeDirectory + "/"

    allFiles = os.listdir(fileDirectory)

    # Refine all files, listing only those of the specified file extension
    returnFiles = []
    for f in allFiles:
        splitString = str(f).rpartition(fileExtension)

        if not splitString[1] == "" and splitString[2] == "":
            returnFiles.append(splitString[0])

    return returnFiles
Example #4
0
def findAllTemplateFiles(relativeDirectory):
    import System.directoryExtension as directoryExtension
    dirExt = directoryExtension.DirectoryExtension()
    artPath = dirExt.artPath

    fileDirectory = artPath + relativeDirectory + "/"

    return findAllFiles(relativeDirectory, fileDirectory, ".ma")
Example #5
0
    def __init__(self, *args):
        """ Call animationModuleSettings """
        self.animMods = animModSettings.AnimMod_Info()

        import System.directoryExtension as dirExt

        dirExt = dirExt.DirectoryExtension()
        self.animDir = dirExt.paths['animLib']
Example #6
0
 def __init__(self):
     print 'init batch tools'
     self.characterName = turbineUtils.getCharacterInfo()[0]
     self.characterPrefix = turbineUtils.getCharacterInfo()[2]
     
     import System.directoryExtension as dirExt
     dirExt = dirExt.DirectoryExtension()
     self.animDir = dirExt.paths['animLib']
    def chooseDirectory(self, *args):
        """ Define the artPath """
        import System.directoryExtension as directoryExtension
        dirExt = directoryExtension.DirectoryExtension()
        artPath = dirExt.artPath
        
        radioState = cmds.radioButtonGrp(self.UIElements['checkBoxA'], q=True, sl=True)

        if radioState == 1:
            directory = (artPath + 'character/GEPPETTO/Animation/animLib/')
        if radioState == 2:
            directory = (artPath + 'character/')
Example #8
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)
Example #9
0
    def __init__(self):
        """ Initialize class and variables """
        # Use the character name to determine the name of the setup node
        self.characterName = turbineUtils.getCharacterInfo()[0]
        self.characterPrefix = turbineUtils.getCharacterInfo()[2]
        self.exportPrefix = self.characterPrefix.replace('Character__', 'Export__')
        
        self.dirExt = dirExt.DirectoryExtension() 
        
        """ Define the character_container """
        self.characterContainer = (self.characterPrefix + ':character_container')

        """ Define the export_container """
        self.exportContainer = (self.exportPrefix + ':Setup')
Example #10
0
 def batchSaveToAnimLib(self, *args):
     """ Define the artPath """
     import System.directoryExtension as directoryExtension
     dirExt = directoryExtension.DirectoryExtension()
     artPath = dirExt.artPath
     
     extension = "*.ma"
     
     files = cmds.fileDialog2(fileFilter=extension, cap='Select Animations', dialogStyle=2, fm=4, okc='OK', dir=artPath)
     try:
         for file in files:
             cmds.file(file, open=True)
             animName = self.getSceneName()
             self.exportAnim(animName)
     except: print "Browser window closed or export failed. """
    def __init__(self, *args):
        """ Create a dictionary to store the character name
        Run a function to get character name """
        self.characterInfo = {}
        try:
            self.characterInfo['characterNamespace'] = self.findCharacterNames(
            )[0]
            self.characterInfo['characterName'] = self.findCharacterNames()[1]
        except:
            return

        import System.moduleMaintenanceEx as moduleMaintenance
        #modMaintenance = moduleMaintenance.ModuleMaintenanceEx(self)
        import System.directoryExtension as dirExt
        dirExt = dirExt.DirectoryExtension()
        self.animDir = dirExt.paths['animLib']
Example #12
0
    def initCsvReader(self, characterName):

        self.characterName = characterName

        # Define the file name and path
        userName = userUtils.getUser()[0]
        outFileSuffix = '_gameJntInfo.csv'
        outFile = (characterName + outFileSuffix)
        """ Define the artPath """
        import System.directoryExtension as directoryExtension
        dirExt = directoryExtension.DirectoryExtension()
        artPath = dirExt.artPath

        filePath = artPath + "/character/GEPPETTO/Data/Character/"

        finalPath = (filePath + outFile)

        reader = csv.reader(open(finalPath, 'rb'), delimiter=',')

        return reader
Example #13
0
 def importAnim(self, *args): 
     """ Define the artPath """
     import System.directoryExtension as directoryExtension
     dirExt = directoryExtension.DirectoryExtension()
     artPath = dirExt.artPath
     
     
     animName = cmds.textScrollList(self.UIElements["animationList"], q=True, si=True)
     print animName
     animLen = len(animName)
     print animLen
     characterShortName = self.shortenCharacterName()
     print characterShortName
     if animLen == 1:
         print "FUICKU"
         self.importAnimProc(animName)
     if animLen > 1:
         print "poop"
         directory = cmds.fileDialog2(cap='Choose Directory', dialogStyle=2, fm=3, okc='OK', dir=artPath)
         for anim in animName:
             self.refCharacterInNewFile()
Example #14
0
def setupDirs(characterName, create=False):
    """ Using this to switch art path for now """
    """ Define the artPath """
    import System.directoryExtension as directoryExtension
    dirExt = directoryExtension.DirectoryExtension()
    artPath = dirExt.artPath

    characterDir = artPath + "character\\" + characterName

    setupDir = characterDir + "\\export\\"
    xmlDir = artPath + "character\\GEPPETTO\\Data\\"
    rigDir = artPath + "character\\GEPPETTO\\Rig\\"
    skinDir = characterDir + "\\skin\\"
    meshDir = characterDir + "\\mesh\\"
    #setDir = characterDir + "\\setup\\"
    wipDir = characterDir + "\\rig\\wip\\"

    # Specific paths to specific character files

    characterFileName = rigDir + characterName + ".ma"
    #setupFileName = setupDir + characterName + "_setup" + ".ma"
    setupFileName = setupDir + characterName + ".ma"
    xmlFileName = xmlDir + characterName + "_xml" + ".xml"

    # I am going to create a directory setup for this character if one does not exist.
    if create:
        #directories = (characterDir, setupDir, xmlDir, rigDir, skinDir)
        directories = (characterDir, setupDir, skinDir, wipDir)
        for dir in directories:
            try:
                os.makedirs(dir)
            except OSError:
                pass

    # Should we try to create the directory if it does not exist?
    # The user may have deleted it.

    return (characterDir, setupDir, xmlDir, rigDir, skinDir, characterFileName,
            setupFileName, xmlFileName, meshDir)
Example #15
0
    def saveDelCharFile(self, characterName):
        """ This process happens at character publish.  The temp .csv file will be saved to a new directory with the character name as prefix """
        self.characterName = characterName
        """ Write the csv with all the character info """
        """ Define the artPath """
        import System.directoryExtension as directoryExtension
        dirExt = directoryExtension.DirectoryExtension()
        artPath = dirExt.artPath

        # Define the file name and path
        userName = userUtils.getUser()[0]

        outFileSuffix = '_gameJntInfo.csv'
        outFileSuffixBU = '_gameJntInfo_BU.csv'

        outFileD = (userName + outFileSuffix)  # Delete this
        outFileS = (self.characterName + outFileSuffix)  # Save as this
        outFileBU = (self.characterName + outFileSuffixBU)  # Save as this

        filePath = artPath + "/character/GEPPETTO/Data/"
        filePathS = artPath + "/character/GEPPETTO/Data/Character/"
        filePathBU = artPath + "/character/GEPPETTO/Data/Character/BU/"

        finalPathD = (filePath + outFileD)
        finalPathS = (filePathS + outFileS)
        finalPathBU = (filePathBU + outFileBU)

        if cmds.file(finalPathS, q=True, ex=True):
            turbineUtils.archiveFile(finalPathS)

        if cmds.file(finalPathD, q=True, ex=True):
            import shutil
            shutil.copy(finalPathD, finalPathS)
            os.remove(finalPathD)
        else:
            cmds.headsUpMessage(
                "No character data file exists for publish.  Please lock a character."
            )
Example #16
0
    def __init__(self, *args):
        import System.directoryExtension as dirExt
        reload(dirExt)
        dirExt = dirExt.DirectoryExtension()
        self.animDir = dirExt.paths['animLib']
        """ Call animationModuleSettings """
        self.animMods = animModSettings.AnimMod_Info()
        #animMods = self.animMods

        self.animLib = animLibrary.animLibFuncs()
        #animLib = self.animLib

        try:
            characterName = self.animMods.characterInfo['characterName']

        except:
            cmds.headsUpMessage("no valid characters in this scene")
            if cmds.window("animLibWindow", exists=True):
                cmds.deleteUI("animLibWindow")
            return
        """ If the lib directory does not exist, create it. """
        turbineUtils.ensure_dir(self.animDir)
        """ Find all the files in the animation lib directory """
        anims = turbineUtils.findAllFiles(self.animDir, ".ma")
        """ Get the name of the animation file to use as a starting point for naming the output from animLib """
        sceneName = cmds.file(q=True, sn=True, shn=True).replace(".ma", "")
        """ Store the UI elements in a dictionary """
        self.animLibUIElements = {}
        """ If the window exists, delete it. """
        if cmds.window("animLibWindow", exists=True):
            cmds.deleteUI("animLibWindow")

        self.windowWidth = 440
        self.windowHeight = 320

        buttonWidth = 100
        textWidth = 140
        columnOffset = 5
        buttonColumnWidth = buttonWidth + (2 * columnOffset)
        textScrollWidth = (self.windowWidth - buttonColumnWidth)
        fieldWidth = (textScrollWidth - 10)
        fieldHeight = (self.windowHeight - 40)

        # Create the main window
        mainWindow = self.animLibUIElements["window"] = cmds.window(
            "animLibWindow", s=True, rtf=True)

        child1 = self.animLibUIElements["listBoxRowLayout"] = cmds.rowLayout(
            nc=2,
            columnWidth2=[buttonWidth, textScrollWidth],
            columnAttach=([1, "left", columnOffset], [2, "both",
                                                      columnOffset]),
            rowAttach=([1, "top", columnOffset], [2, "top", columnOffset]))

        # Create a couple flow layouts to hold the UI Elements for setup tools
        self.animLibUIElements["buttonColumnLayout"] = cmds.flowLayout(v=True)
        cmds.setParent('..')

        self.animLibUIElements["characterColumnLayout"] = cmds.flowLayout(
            v=True)
        cmds.setParent('..')

        # Create the setup UI elements
        cmds.setParent(self.animLibUIElements["characterColumnLayout"])
        self.animLibUIElements["nameField"] = cmds.textField(tx=sceneName,
                                                             width=fieldWidth)
        cmds.separator(height=7, style='in')
        self.animLibUIElements["animationList"] = cmds.textScrollList(
            numberOfRows=4,
            allowMultiSelection=False,
            append=anims,
            selectIndexedItem=1,
            width=fieldWidth,
            h=fieldHeight)

        cmds.setParent(self.animLibUIElements["buttonColumnLayout"])
        self.animLibUIElements['saveAnimButton'] = cmds.button(
            label='Save Anim As', width=buttonWidth, c=self.exportAnimCurves)
        cmds.separator(height=5, style='in')
        self.animLibUIElements['loadAnimButton'] = cmds.button(
            label='Load Animation',
            width=buttonWidth,
            h=100,
            c=self.importAnim)

        cmds.setParent(self.animLibUIElements["window"])

        cmds.showWindow(self.animLibUIElements["window"])