def exportHData(asset): # get publish maya file pubMayaFile = asset.publishFile() # replace to yml pubHDataFile = pubMayaFile.replace(".ma", ".yml") hDir = asset.rigDataPath("hdata") hFileName = "%s/%s" % (hDir, os.path.basename(pubHDataFile)) if not os.path.exists(hDir): os.makedirs(hDir) if not os.path.exists(os.path.dirname(pubHDataFile)): os.makedirs(os.path.dirname(pubHDataFile)) result = pt.exportHierarchyData(setting.exportGrp, pubHDataFile) if result: # copy to work area fileUtils.copy(pubHDataFile, hFileName) status = False if result: status = True return {"Export H-Data": {"status": status, "message": "", "hero": result}}
def exportData(assetName, exportPath): info = setting.cachePathInfo() configData = dict() sceneInfo = setting.getSceneInfo() dept = sceneInfo['department'] if info: if exportDept == dept: cachePath = info['cacheInfoPath'] shadeFile = str(getShaderPath(assetName)['shadeFile']) shadeDataFile = str(getShaderPath(assetName)['dataFile']) assetPath = str(getShaderPath(assetName)['assetFile']) cacheGrp = str('%s:%s' % (assetName, exportGrp)) assetDataPath = info['assetDataPath'] if os.path.exists(cachePath): config = open(cachePath, 'r') configData = yaml.load(config) if not os.path.exists(os.path.dirname(cachePath)): os.makedirs(os.path.dirname(cachePath)) print os.path.dirname(cachePath) fileInfo = open(cachePath, 'w') configData.update({ str(assetName): { 'shadeFile': shadeFile, 'shadeDataFile': shadeDataFile, 'cachePath': str(exportPath), 'assetPath': assetPath, 'cacheGrp': cacheGrp } }) result = yaml.dump(configData, fileInfo, default_flow_style=False) # export asset hierarchy if not os.path.exists(assetDataPath): os.makedirs(assetDataPath) # export asset data dataPath = '%s/%s.yml' % (assetDataPath, assetName) pipelineTools.exportHierarchyData(cacheGrp, dataPath) print dataPath
def exportData(assetName, exportPath) : info = setting.cachePathInfo() configData = dict() sceneInfo = setting.getSceneInfo() dept = sceneInfo['department'] if info : if exportDept == dept : cachePath = info['cacheInfoPath'] shadeFile = str(getShaderPath(assetName)['shadeFile']) shadeDataFile = str(getShaderPath(assetName)['dataFile']) assetPath = str(getShaderPath(assetName)['assetFile']) cacheGrp = str('%s:%s' % (assetName, exportGrp)) assetDataPath = info['assetDataPath'] if os.path.exists(cachePath) : config = open(cachePath, 'r') configData = yaml.load(config) if not os.path.exists(os.path.dirname(cachePath)) : os.makedirs(os.path.dirname(cachePath)) print os.path.dirname(cachePath) fileInfo = open(cachePath, 'w') configData.update({str(assetName): {'shadeFile': shadeFile, 'shadeDataFile': shadeDataFile, 'cachePath': str(exportPath), 'assetPath': assetPath, 'cacheGrp': cacheGrp}}) result = yaml.dump(configData, fileInfo, default_flow_style = False) # export asset hierarchy if not os.path.exists(assetDataPath) : os.makedirs(assetDataPath) # export asset data dataPath = '%s/%s.yml' % (assetDataPath, assetName) pipelineTools.exportHierarchyData(cacheGrp, dataPath) print dataPath
def doExportCache(self): logger.debug('def doExportCache') logger.info('--------------------------') logger.info('Start exporting ...') startTime = datetime.now() # get list allStatus = self.ui.exportCacheAll_checkBox.isChecked() # cachePath cachePath = str(self.ui.cache_lineEdit.text()) # asset data path assetDataPath = self.getCachePathInfo(True)['assetDataPath'] listWidget = 'cache_listWidget' assetList = [] itemWidgets = [] # optimized viewport hook.isolateObj(True) if allStatus: items = self.getAllItems(listWidget) assetList = items[1] itemWidgets = items[2] else: items = self.getSelectedItems(listWidget) assetList = items[1] itemWidgets = items[2] if assetList: i = 0 for eachAsset in assetList: if eachAsset in self.assetInfo: # get export group cacheGrp = self.assetInfo[eachAsset]['cacheGrp'] namespace = self.assetInfo[eachAsset]['namespace'] # set status itemWidgets[i].setIcon(self.ipIcon, self.iconSize) QtGui.QApplication.processEvents() # collect time cacheStartTime = datetime.now() # do cache hook.refresh(False) result = abcExport.doExportUICall(namespace, cacheGrp, cachePath) hook.refresh(True) # do export anim curve try: hook.exportAnim(namespace, self.animCurvePath) logger.debug('Export animcurve %s/%s.anim' % (self.animCurvePath, namespace)) except Exception as e: logger.debug('Export Anim curve failed') logger.debug(e) if result: logger.info('Export %s to %s complete' % (cacheGrp, result)) # set status itemWidgets[i].setIcon(self.okIcon, self.iconSize) QtGui.QApplication.processEvents() cacheEndTime = datetime.now() cacheDuration = cacheEndTime - cacheStartTime # collect info self.addAssetLog(namespace, cacheGrp) self.addTimeLog('asset', namespace, cacheDuration) # export asset hierarchy if not os.path.exists(assetDataPath): os.makedirs(assetDataPath) # export asset data dataPath = '%s/%s.yml' % (assetDataPath, namespace) pipelineTools.exportHierarchyData(cacheGrp, dataPath) logger.debug('export asset data %s' % dataPath) i += 1 hook.isolateObj(False) finishTime = datetime.now() duration = finishTime - startTime self.addTimeLog('shot', '', duration) logger.info('Finish export') logger.info('%s' % duration) self.messageBox('Complete', 'Cache complete in %s seconds' % str(duration))
def doExportCache(self) : logger.debug('def doExportCache') logger.info('--------------------------') logger.info('Start exporting ...') startTime = datetime.now() # get list allStatus = self.ui.exportCacheAll_checkBox.isChecked() # cachePath cachePath = str(self.ui.cache_lineEdit.text()) # asset data path assetDataPath = self.getCachePathInfo(True)['assetDataPath'] listWidget = 'cache_listWidget' assetList = [] itemWidgets = [] # optimized viewport hook.isolateObj(True) if allStatus : items = self.getAllItems(listWidget) assetList = items[1] itemWidgets = items[2] else : items = self.getSelectedItems(listWidget) assetList = items[1] itemWidgets = items[2] if assetList : i = 0 for eachAsset in assetList : if eachAsset in self.assetInfo : # get export group cacheGrp = self.assetInfo[eachAsset]['cacheGrp'] namespace = self.assetInfo[eachAsset]['namespace'] # set status itemWidgets[i].setIcon(self.ipIcon, self.iconSize) QtGui.QApplication.processEvents() # collect time cacheStartTime = datetime.now() # do cache hook.refresh(False) result = abcExport.doExportUICall(namespace, cacheGrp, cachePath) hook.refresh(True) # do export anim curve try : hook.exportAnim(namespace, self.animCurvePath) logger.debug('Export animcurve %s/%s.anim' % (self.animCurvePath, namespace)) except Exception as e : logger.debug('Export Anim curve failed') logger.debug(e) if result : logger.info('Export %s to %s complete' % (cacheGrp, result)) # set status itemWidgets[i].setIcon(self.okIcon, self.iconSize) QtGui.QApplication.processEvents() cacheEndTime = datetime.now() cacheDuration = cacheEndTime - cacheStartTime # collect info self.addAssetLog(namespace, cacheGrp) self.addTimeLog('asset', namespace, cacheDuration) # export asset hierarchy if not os.path.exists(assetDataPath) : os.makedirs(assetDataPath) # export asset data dataPath = '%s/%s.yml' % (assetDataPath, namespace) pipelineTools.exportHierarchyData(cacheGrp, dataPath) logger.debug('export asset data %s' % dataPath) i += 1 hook.isolateObj(False) finishTime = datetime.now() duration = finishTime - startTime self.addTimeLog('shot', '', duration) logger.info('Finish export') logger.info('%s' % duration) self.messageBox('Complete', 'Cache complete in %s seconds' % str(duration))