class ExportParse(ParseSchema): """ Class to solve for the export tools """ def __init__(self, filePath='', team=''): super(ExportParse, self).__init__() # Solve needed attributes from the xml self.runTimeArtRoot = eval(self.exportList.get("runTimeArtRoot")) self.exportKey = self.exportList.get("exportKey") # Set needed variables if self.filePath: if os.path.isdir(self.filePath): self.exportSourceFolder = self.filePath + '/' else: self.exportSourceFolder = os.path.dirname(self.filePath) + '/' else: logger.warning('No scene selected') #self.exportSourceFolder = '/' def getExport(self, wFile=0): """ Method that returns folder for exporting meshes, animations (Character & Environment) """ #assert(self.exportSourceFolder), "" if not self.filePath or not self.exportSourceFolder: return if self.team == gv.teamA: self.exportKey = int(self.exportKey) if wFile: self.exportPath = ( '%s%s' % (self.exportSourceFolder.rsplit('/', (self.exportKey + 1))[0] + '/', self.filePath[self.filePath.rfind('/') + 1:]) ).replace(".ma", ".gr2").replace(".mb", "gr2") else: self.exportPath = self.exportSourceFolder.rsplit( '/', (self.exportKey + 1))[0] + '/' #print 'printStatement: ' + self.exportSourceFolder logger.debug('Export folder: %s' % self.exportSourceFolder) return self.exportPath elif self.team == gv.teamB: if re.search('Animations', self.filePath): self.exportFileName = self.filePath.basename().replace( ".ma", ".xmd").replace(".mb", ".xmd").replace(".fbx", ".xmd") rigPath = self.filePath[:self.filePath.rfind('MoBu')] weapon = self.exportFileName.split('_')[1] self.exportPath = Path('%s/Morpheme/Animations/%s/%s' % (rigPath, weapon, self.exportFileName)) else: self.exportPath = Path( self.filePath.replace(".ma", ".gr2").replace(".mb", "gr2")) if not wFile: self.exportPath = self.exportPath.parent return self.exportPath.makePretty() elif self.team == gv.teamD: strFrom = self.exportKey[self.exportKey.find(':', 2) + 1:self.exportKey.rfind(':', 1)] #print strFrom strTo = self.exportKey[self.exportKey.rfind(':', 1) + 1:] #print strTo self.exportPath = self.exportSourceFolder.replace(strFrom, strTo) if wFile: self.exportPath = '%s%s' % ( self.exportPath, self.filePath[self.filePath.rfind('/') + 1:]) return self.exportPath elif self.team == gv.teamD: # If the asset is an environment asset if re.match(self.environmentRoot, self.exportSourceFolder): envMeshKey = self.exportList.get('environmentMeshExportKey') envMeshKeySource = envMeshKey[envMeshKey.find(':', 2) + 1:envMeshKey.rfind(':', 1)] envMeshKeyTarget = envMeshKey[envMeshKey.rfind(':', 1) + 1:] envAnimKey = self.exportList.get('environmentAnimExportKey') envAnimKeySource = envAnimKey[envAnimKey.find(':', 2) + 1:envAnimKey.rfind(':', 1) - 3] envAnimKeyTarget = envAnimKey[envAnimKey.rfind(':', 1) + 1:] # If the environment asset is an animation if re.search(envAnimKeySource, self.exportSourceFolder): self.exportPath = self.exportSourceFolder.split( envAnimKeySource)[0] + envAnimKeyTarget if wFile: self.exportPath = '%s%s' % ( self.exportPath, self.filePath[self.filePath.rfind('/') + 1:]) if self.exportPath: return self.exportPath # If the asset is not an animation else: self.exportPath = self.exportSourceFolder.replace( envMeshKeySource, envMeshKeyTarget) if wFile: self.exportPath = '%s%s' % ( self.exportPath, self.filePath[self.filePath.rfind('/') + 1:]) if self.exportPath: return self.exportPath # If the asset is a character asset if re.match(self.characterRoot, self.exportSourceFolder): charMeshKey = self.exportList.get('characterMeshExportKey') charMeshKeySource = charMeshKey[charMeshKey.find(':', 2) + 1:charMeshKey.rfind(':', 1)] charMeshKeyTarget = charMeshKey[charMeshKey.rfind(':', 1) + 1:] charAnimKey = self.exportList.get('characterAnimExportKey') charAnimKeySource = charAnimKey[charAnimKey.find(':', 2) + 1:charAnimKey.rfind(':', 1) - 3] charAnimKeyTarget = charAnimKey[charAnimKey.rfind(':', 1) + 1:] # If the character asset is an animation if re.search(charAnimKeySource, self.exportSourceFolder): self.exportPath = self.exportSourceFolder.split( charAnimKeySource)[0] + charAnimKeyTarget if wFile: self.exportPath = '%s%s' % ( self.exportPath, self.filePath[self.filePath.rfind('/') + 1:]) if self.exportPath: return self.exportPath # If the asset is not an animation else: self.exportPath = self.exportSourceFolder.replace( charMeshKeySource, charMeshKeyTarget) if wFile: self.exportPath = '%s%s' % ( self.exportPath, self.filePath[self.filePath.rfind('/') + 1:]) if self.exportPath: return self.exportPath def getRunTimeArt(self, wFile=0): """ method to return the folder (or w/ file) for the run time copy """ fileLoc = self.getExport(wFile) runTimeFilePath = fileLoc.replace(self.characterRoot, self.runTimeArtRoot) return runTimeFilePath def getRunTime(self): return self.runTimeArtRoot[:self.runTimeArtRoot.rfind('Runtime') + 8]
class ExportParse(ParseSchema): """ Class to solve for the export tools """ def __init__(self, filePath='', team=''): super(ExportParse, self).__init__() # Solve needed attributes from the xml self.runTimeArtRoot = eval(self.exportList.get("runTimeArtRoot")) self.exportKey = self.exportList.get("exportKey") # Set needed variables if self.filePath: if os.path.isdir(self.filePath): self.exportSourceFolder = self.filePath + '/' else: self.exportSourceFolder = os.path.dirname(self.filePath) + '/' else: logger.warning('No scene selected') #self.exportSourceFolder = '/' def getExport(self, wFile=0): """ Method that returns folder for exporting meshes, animations (Character & Environment) """ #assert(self.exportSourceFolder), "" if not self.filePath or not self.exportSourceFolder: return if self.team == gv.teamA: self.exportKey = int(self.exportKey) if wFile: self.exportPath = ('%s%s' % (self.exportSourceFolder.rsplit('/', (self.exportKey + 1))[0] + '/', self.filePath[self.filePath.rfind('/') + 1:])).replace(".ma", ".gr2").replace( ".mb", "gr2") else: self.exportPath = self.exportSourceFolder.rsplit('/', (self.exportKey + 1))[0] + '/' #print 'printStatement: ' + self.exportSourceFolder logger.debug('Export folder: %s' % self.exportSourceFolder) return self.exportPath elif self.team == gv.teamB: if re.search('Animations', self.filePath): self.exportFileName = self.filePath.basename().replace(".ma", ".xmd").replace(".mb", ".xmd").replace( ".fbx", ".xmd") rigPath = self.filePath[:self.filePath.rfind('MoBu')] weapon = self.exportFileName.split('_')[1] self.exportPath = Path('%s/Morpheme/Animations/%s/%s' % (rigPath, weapon, self.exportFileName)) else: self.exportPath = Path(self.filePath.replace(".ma", ".gr2").replace(".mb", "gr2")) if not wFile: self.exportPath = self.exportPath.parent return self.exportPath.makePretty() elif self.team == gv.teamD: strFrom = self.exportKey[self.exportKey.find(':', 2) + 1:self.exportKey.rfind(':', 1)] #print strFrom strTo = self.exportKey[self.exportKey.rfind(':', 1) + 1:] #print strTo self.exportPath = self.exportSourceFolder.replace(strFrom, strTo) if wFile: self.exportPath = '%s%s' % (self.exportPath, self.filePath[self.filePath.rfind('/') + 1:]) return self.exportPath elif self.team == gv.teamD: # If the asset is an environment asset if re.match(self.environmentRoot, self.exportSourceFolder): envMeshKey = self.exportList.get('environmentMeshExportKey') envMeshKeySource = envMeshKey[envMeshKey.find(':', 2) + 1:envMeshKey.rfind(':', 1)] envMeshKeyTarget = envMeshKey[envMeshKey.rfind(':', 1) + 1:] envAnimKey = self.exportList.get('environmentAnimExportKey') envAnimKeySource = envAnimKey[envAnimKey.find(':', 2) + 1:envAnimKey.rfind(':', 1) - 3] envAnimKeyTarget = envAnimKey[envAnimKey.rfind(':', 1) + 1:] # If the environment asset is an animation if re.search(envAnimKeySource, self.exportSourceFolder): self.exportPath = self.exportSourceFolder.split(envAnimKeySource)[0] + envAnimKeyTarget if wFile: self.exportPath = '%s%s' % (self.exportPath, self.filePath[self.filePath.rfind('/') + 1:]) if self.exportPath: return self.exportPath # If the asset is not an animation else: self.exportPath = self.exportSourceFolder.replace(envMeshKeySource, envMeshKeyTarget) if wFile: self.exportPath = '%s%s' % (self.exportPath, self.filePath[self.filePath.rfind('/') + 1:]) if self.exportPath: return self.exportPath # If the asset is a character asset if re.match(self.characterRoot, self.exportSourceFolder): charMeshKey = self.exportList.get('characterMeshExportKey') charMeshKeySource = charMeshKey[charMeshKey.find(':', 2) + 1:charMeshKey.rfind(':', 1)] charMeshKeyTarget = charMeshKey[charMeshKey.rfind(':', 1) + 1:] charAnimKey = self.exportList.get('characterAnimExportKey') charAnimKeySource = charAnimKey[charAnimKey.find(':', 2) + 1:charAnimKey.rfind(':', 1) - 3] charAnimKeyTarget = charAnimKey[charAnimKey.rfind(':', 1) + 1:] # If the character asset is an animation if re.search(charAnimKeySource, self.exportSourceFolder): self.exportPath = self.exportSourceFolder.split(charAnimKeySource)[0] + charAnimKeyTarget if wFile: self.exportPath = '%s%s' % (self.exportPath, self.filePath[self.filePath.rfind('/') + 1:]) if self.exportPath: return self.exportPath # If the asset is not an animation else: self.exportPath = self.exportSourceFolder.replace(charMeshKeySource, charMeshKeyTarget) if wFile: self.exportPath = '%s%s' % (self.exportPath, self.filePath[self.filePath.rfind('/') + 1:]) if self.exportPath: return self.exportPath def getRunTimeArt(self, wFile=0): """ method to return the folder (or w/ file) for the run time copy """ fileLoc = self.getExport(wFile) runTimeFilePath = fileLoc.replace(self.characterRoot, self.runTimeArtRoot) return runTimeFilePath def getRunTime(self): return self.runTimeArtRoot[:self.runTimeArtRoot.rfind('Runtime') + 8]