def setAsmVersion(self, root): attr = '%s.version' % root version = 'N/A' if mc.objExists(attr): data = mc.getAttr(attr) if data: asset = entityInfo.info(data) currentVersion = asset.getFileVersion(padding=True) if currentVersion: workPath = ('/').join([ a for a in os.path.dirname(data).split('/') if not a == 'publish' ]) workScene = '%s/scenes/%s' % (workPath, os.path.basename(data)) asset = entityInfo.info(workScene) fileVersion = asset.getFileVersion() publishVersion = asset.getPublishVersion() - 1 if not fileVersion == publishVersion: self.ui.version_label.setText( 'v%03d latest v%03d - Not matched.' % (fileVersion, publishVersion)) else: self.ui.version_label.setText('v%03d - Up to date.' % fileVersion)
def exportShotAsmLocator(bake=False) : """ export multiple sets from shot """ currentObjs = mc.ls(assemblies=True) try : # roots = createAsmLocator(bake) asmLocator = asm.AsmLocator() roots = asmLocator.create() asmRoots = asm.findAssemblyRoot() rootVersions = findAsmVersion(asmRoots) shot = entityInfo.info() exportFiles = [] heroLocs = [] if roots : for i, root in enumerate(roots) : refPath = mc.getAttr('%s.reference' % root) asset = entityInfo.info(refPath) assetName = asset.name() setLocData(root, locType='shotTransform', version=rootVersions[i]) path = shot.animOutput('assemblies', True) hero = shot.animOutput('assemblies', True, False) path = path.replace('$', assetName) hero = hero.replace('$', assetName) logger.info('--------- Exporting to Alembic --------------') logger.info('%s/%s' % (i, len(roots))) currentTime = mc.currentTime(q = True) start = currentTime end = currentTime + 1 versionLoc = abcUtils.exportABC(['|'+root], path, start, end) print 'Export %s' % versionLoc heroLoc = fileUtils.copy(path, hero) print 'Copy to hero %s' % heroLoc mc.delete(['|'+root]) heroLocs.append(heroLoc) print 'Total %s set(s)' % len(roots) return heroLocs except Exception as e : newObjs = mc.ls(assemblies=True) addObjs = list(set(newObjs) - set(currentObjs)) logger.warning('Create locator failed. Remove left over objects %s' % addObjs) # mc.delete(addObjs) logger.error(e) traceback.print_exc()
def findShotAsmSetAds() : setGrp = '|set' ads = [] validAds = [] assetNames = [] locs = [] assets = [] if mc.objExists(setGrp) : nodes = mc.listRelatives(setGrp, c=True) if nodes : ads = ads + nodes ads = ads + [a for a in mc.ls(assemblies=True) if mc.objectType(a, isType = 'assemblyReference')] for ad in ads : path = mc.getAttr('%s.definition' % ad) asset = entityInfo.info(path) if asset.type() == 'set' : validAds.append(ad) assetNames.append(asset.name()) locs.append(asset.getRefNaming('loc')) assets.append(asset) return validAds
def findSetName(self): asset = entityInfo.info() setName = '%s%s_*_fixSet' % (asset.department(), asset.taskLOD().capitalize()) sets = mc.ls(setName) if sets: return sets[0]
def exportABC(target = 'latest') : """ from tool.publish.asset import assetPublish_utils as utils reload(utils) utils.exportABC('latest') """ asset = entityInfo.info() abcDir = asset.rigDataPath('abc') files = fileUtils.listFile(abcDir) if target == 'latest' : if files : latest = files[-1] path = '%s/%s' % (abcDir, latest) else : target = 'publish' if target == 'publish' : publishFile = os.path.basename(asset.publishFile()) abcFile = publishFile.replace('.ma', '.abc') path = '%s/%s' % (abcDir, abcFile) result = exportABCCmd(path) if result : print 'Export success %s' % path
def texturePath() : from tool.utils import entityInfo reload(entityInfo) nodes = mc.ls(type = 'file') paths = [] if nodes : for each in nodes : path = mc.getAttr('%s.fileTextureName' % each) paths.append(path) asset = entityInfo.info() assetPath = asset.texturePath() invalidPath = [] if asset.department() in setting.textureCheckStep : if paths : for each in paths : if not assetPath in each : invalidPath.append(each) if invalidPath : return [False, invalidPath] else : return [True, invalidPath] else : return [True, 'Not check for this department']
def doImportVrayNodes2(): # get from geo_grp in the scene grps = mc.ls('*:Geo_Grp') dataFiles = [] for eachAsset in grps: # get path attr = '%s.ref' % eachAsset lodAttr = '%s.lod' % eachAsset if mc.objExists(attr) and mc.objExists(lodAttr): ref = mc.getAttr(attr) lod = mc.getAttr(lodAttr) # instance asset.info asset = entityInfo.info('%s/_%s' % (ref, lod)) dataPath = asset.getPath('refData') dataFile = asset.getRefNaming('vrayNodeData') dataFilePath = '%s/%s' % (dataPath, dataFile) if not dataFilePath in dataFiles: dataFiles.append(dataFilePath) if dataFiles: for dataFile in dataFiles: if os.path.exists(dataFile): importVrayNodes(dataFile) else: print 'Path not exists %s' % dataFile
def doImportVrayNodes2() : # get from geo_grp in the scene grps = mc.ls('*:Geo_Grp') dataFiles = [] for eachAsset in grps : # get path attr = '%s.ref' % eachAsset lodAttr = '%s.lod' % eachAsset if mc.objExists(attr) and mc.objExists(lodAttr) : ref = mc.getAttr(attr) lod = mc.getAttr(lodAttr) # instance asset.info asset = entityInfo.info('%s/_%s' % (ref, lod)) dataPath = asset.getPath('refData') dataFile = asset.getRefNaming('vrayNodeData') dataFilePath = '%s/%s' % (dataPath, dataFile) if not dataFilePath in dataFiles : dataFiles.append(dataFilePath) if dataFiles : for dataFile in dataFiles : if os.path.exists(dataFile) : importVrayNodes(dataFile) else : print 'Path not exists %s' % dataFile
def initData(self) : # data self.asset = entityInfo.info() self.statusMap = self.getProjectSetting('statusMap') self.outputMap = self.getProjectSetting('outputMap') self.svPublishFile = self.asset.publishFile() self.logFile = self.asset.getLogPath()
def getAssetSelection(self): objs = mc.ls(sl=True) assets = [] namespaces = [] if objs: for obj in objs: if mc.referenceQuery(obj, inr=True): path = mc.referenceQuery(obj, f=True) asset = entityInfo.info(path) if not asset.name() in assets: assets.append(asset.name()) else: namespace = obj.split(':')[0] if not namespace in namespaces: namespaces.append(namespace) for namespace in namespaces: attr = '%s:Geo_Grp.assetName' % namespace if mc.objExists(attr): assetName = mc.getAttr(attr) if not assetName in assets: assets.append(assetName) return assets
def getAssetInfo(self) : # list asset from reference refs = mc.file(q = True, r = True) rigGrp = mc.ls('*:Rig_Grp') assetInfo = dict() for eachRef in refs : if pipelineTools.checkPipelinePath(eachRef, mode = 'asset') : asset = entityInfo.info(eachRef) assetName = asset.name() assetPath = asset.getPath('ref') record = self.getObjectIDRecord(assetName) if assetName and record : oID = record[1] dbAssetName = record[2] dbAssetPath = record[3] dbUser = record[4] dbMatteRange = record[5] if not assetName in assetInfo.keys() : assetInfo.update({assetName: {'db': True, 'oID': oID, 'assetName': dbAssetName, 'assetPath': dbAssetPath, 'user': dbUser, 'matteIDs': dbMatteRange, 'No': 1}}) else : assetInfo[assetName]['No'] += 1 else : if not assetName in assetInfo.keys() : assetInfo.update({assetName: {'db': False, 'oID': None, 'assetName': assetName, 'assetPath': assetPath, 'user': None, 'matteIDs': None, 'No': 1}}) return assetInfo
def run(SCENEPATH): # print MAYA_PYTHON, MAYACMD, ARPATH, ADPATH, ADNAME, ASSETNAME logger.info('Start exporting asmAssetLocator ...') asset = entityInfo.info(SCENEPATH) locPath = '%s/%s' % (asset.getPath('ref'), asset.getRefNaming('loc')) mtime = None if os.path.exists(locPath): logger.debug('File exists. Backing up ...') backupResult = pipelineTools.backupRef(locPath) logger.debug('Backup complete %s' % locPath) mtime = os.path.getmtime(locPath) logger.debug('mtime %s' % mtime) logFile = 'asmExportLoc_%s.log' % str(datetime.now()).replace( ' ', '_').replace(':', '-').split('.')[0] logPath = '%s/%s/%s' % (asset.getPath('log'), 'asmLocator', logFile) # logPath = LOG logger.info('running batch ...') chk = subprocess.call([MAYA_PYTHON, MAYACMD, SCENEPATH]) logger.debug('batch complete') chk = ''
def findAssemblyRoot(): setGrp = '|set' topNodes = mc.ls(assemblies=True) topNodes = [ a for a in topNodes if mc.objectType(a, isType='assemblyReference') ] adNodes = topNodes setNodes = [] if mc.objExists(setGrp): setMembers = mc.listRelatives(setGrp, c=True) setMembers = [ a for a in setMembers if mc.objectType(a, isType='assemblyReference') ] if setMembers: adNodes = adNodes + setMembers for eachNode in adNodes: definition = mc.getAttr('%s.definition' % eachNode) asset = entityInfo.info(definition) if asset.type() in ['set', 'subSet', 'setDress']: setNodes.append(eachNode) return setNodes
def getAnimLatestFile(self): shot = entityInfo.info() animPath = '%s/scenes/work' % shot.getPath(dept='anim') workFiles = fileUtils.listFile(animPath) if workFiles: return '%s/%s' % (animPath, workFiles[-1])
def setUI(self): shot = entityInfo.info() animLatestFile = os.path.basename(self.getAnimLatestFile()) self.ui.info_label.setText(str(shot.fileName())) self.ui.anim_label.setText(animLatestFile) self.setTable() self.listSet()
def exportAssetLocator(self, arg=None): asset = entityInfo.info() sd_utils.publishWork(ar=True) sd_utils.publishAD() result = asmAssetExport.run(asset.thisScene()) if result: message = 'Export asset locator complete!' mc.confirmDialog(title='Warning', message=message, button=['OK'])
def doImportShade(): asset = entityInfo.info() assetName = asset.name() refPath = asset.getPath('ref') shadeName = asset.getRefNaming('shade', showExt=False) shadeFile = '%s/%s.ma' % (refPath, shadeName) shadeDataFile = '%s/%s.yml' % (refPath, shadeName) if os.path.exists(shadeFile) and os.path.exists(shadeDataFile): importShade.applyRefShade(assetName, shadeFile, shadeDataFile)
def doImportShade() : asset = entityInfo.info() assetName = asset.name() refPath = asset.getPath('ref') shadeName = asset.getRefNaming('shade', showExt = False) shadeFile = '%s/%s.ma' % (refPath, shadeName) shadeDataFile = '%s/%s.yml' % (refPath, shadeName) if os.path.exists(shadeFile) and os.path.exists(shadeDataFile) : importShade.applyRefShade(assetName, shadeFile, shadeDataFile)
def confirmUsingRig(self): items = self.ui.adRemove_listWidget.selectedItems() shot = entityInfo.info() step = shot.department() if items: for item in items: assetName = str(item.text()) attr = '%s.%s_confirm' % (assetName, step) mc.setAttr(attr, True) self.runCheck(hidePanel=False)
def getShotSetAsset() : data = pipelineTools.readShotAsmSet() if data : sets = [a for a in data['set']] return sets else : shot = entityInfo.info() desFileHero = shot.animOutput(data='description', fileVersion=False) logger.warning('No data file exported %s' % desFileHero)
def publishAD(arFile='') : """ publish ad file from dress work """ logger.info('Publishing AD file ...') asset = entityInfo.info() if not arFile: arFile = '%s/%s' % (asset.getPath('ref'), asset.getRefNaming('ar')) adFile = '%s/%s' % (asset.getPath('ref'), asset.getRefNaming('ad')) adName = '%s_ad' % (asset.name()) createAD.SCENEPATH = asset.thisScene() createAD.ARPATH = arFile createAD.ADPATH = adFile createAD.ADNAME = adName createAD.ASSETNAME = asset.name() logger.debug('setting param ... ') logger.debug('param createAD.SCENEPATH : %s' % createAD.SCENEPATH) logger.debug('param createAD.ARPATH : %s' % createAD.ARPATH) logger.debug('param createAD.ADPATH : %s' % createAD.ADPATH) logger.debug('param createAD.ADNAME : %s' % createAD.ADNAME) logger.debug('param createAD.ASSETNAME : %s' % createAD.ASSETNAME) mtime = None if os.path.exists(adFile): mtime = os.path.getmtime(adFile) logger.debug('File exists. Backing up %s' % arFile) backupResult = pipelineTools.backupRef(adFile) logger.debug('Backup complete %s' % backupResult) try: # pipelineTools.backupRef(self.adPath) logger.debug('Running batch create AD ...') logPath = createAD.run() logger.debug('Batch complete %s' % logPath) except Exception as e : logger.error('Error %s' % e) if os.path.exists(adFile) : if mtime : newMtime = os.path.getmtime(adFile) logger.debug('mtime %s, newMTime %s' % (mtime, newMtime)) if not newMtime == mtime : logger.info('Publish AD complete %s' % adFile) return adFile else : logger.error('Batch publish AD failed. File maybe locked. %s' % adFile) else : logger.info('Publish AD complete %s' % adFile) return adFile
def doExportVrayNodes() : title = 'Export Vray Nodes' asset = entityInfo.info() returnResult = dict() exportPath = asset.getPath('refData') nodeFile = '%s/%s' % (exportPath, asset.getRefNaming('vrayNode')) dataFile = '%s/%s' % (exportPath, asset.getRefNaming('vrayNodeData')) startMTime1 = None startMTime2 = None currentMTime1 = None currentMTime2 = None if os.path.exists(nodeFile) : startMTime1 = os.path.getmtime(nodeFile) if os.path.exists(dataFile) : startMTime2 = os.path.getmtime(dataFile) result = pipelineTools.exportVrayNode(dataFile, nodeFile) dataFileResult = result[0] nodeFileResult = result[1] if dataFileResult : currentMTime1 = os.path.getmtime(dataFileResult) if nodeFileResult : currentMTime2 = os.path.getmtime(nodeFileResult) status = False status1 = False status2 = False message = '' if not currentMTime1 == startMTime1 : status1 = True message += 'Node file export complete - ' if not currentMTime2 == startMTime2 : status2 = True message += 'Node data file export complete' if status1 and status2 : status = True if status : print('---- Vray Nodes Output ---') print(dataFileResult) print(nodeFileResult)
def doExportVrayNodes(): title = 'Export Vray Nodes' asset = entityInfo.info() returnResult = dict() exportPath = asset.getPath('refData') nodeFile = '%s/%s' % (exportPath, asset.getRefNaming('vrayNode')) dataFile = '%s/%s' % (exportPath, asset.getRefNaming('vrayNodeData')) startMTime1 = None startMTime2 = None currentMTime1 = None currentMTime2 = None if os.path.exists(nodeFile): startMTime1 = os.path.getmtime(nodeFile) if os.path.exists(dataFile): startMTime2 = os.path.getmtime(dataFile) result = pipelineTools.exportVrayNode(dataFile, nodeFile) dataFileResult = result[0] nodeFileResult = result[1] if dataFileResult: currentMTime1 = os.path.getmtime(dataFileResult) if nodeFileResult: currentMTime2 = os.path.getmtime(nodeFileResult) status = False status1 = False status2 = False message = '' if not currentMTime1 == startMTime1: status1 = True message += 'Node file export complete - ' if not currentMTime2 == startMTime2: status2 = True message += 'Node data file export complete' if status1 and status2: status = True if status: print('---- Vray Nodes Output ---') print(dataFileResult) print(nodeFileResult)
def run(SCENEPATH): # print MAYA_PYTHON, MAYACMD, ARPATH, ADPATH, ADNAME, ASSETNAME logger.info('Start exporting asmAssetLocator ...') asset = entityInfo.info(SCENEPATH) locPath = '%s/%s' % (asset.getPath('ref'), asset.getRefNaming('loc')) mtime = None if os.path.exists(locPath): logger.debug('File exists. Backing up ...') backupResult = pipelineTools.backupRef(locPath) logger.debug('Backup complete %s' % locPath) mtime = os.path.getmtime(locPath) logger.debug('mtime %s' % mtime) logFile = 'asmExportLoc_%s.log' % str(datetime.now()).replace( ' ', '_').replace(':', '-').split('.')[0] logPath = '%s/%s/%s' % (asset.getPath('log'), 'asmLocator', logFile) # logPath = LOG logger.info('running batch ...') chk = subprocess.call([MAYA_PYTHON, MAYACMD, SCENEPATH]) logger.debug('batch complete') chk = '' if not os.path.exists(os.path.dirname(logPath)): os.makedirs(os.path.dirname(logPath)) logger.debug('writing log ...') f = open(logPath, 'w') f.write(chk) f.close() logger.debug('Complete. %s' % logPath) if os.path.exists(locPath): if mtime: newMTime = os.path.getmtime(locPath) if not newMTime == mtime: logger.info('Export complete : %s' % locPath) return locPath else: logger.error('Export failed. File maybe locked %s' % locPath) else: logger.info('Export complete : %s' % locPath) return locPath
def doShadeExport() : from tool.utils import entityInfo reload(entityInfo) asset = entityInfo.info() groupNames = ['Geo_Grp', 'Rig:Geo_Grp'] # name = '%s_Shade' % asset.name() name = asset.getRefNaming('shade', showExt = False) exportPath = asset.getPath('ref') for groupName in groupNames : if mc.objExists(groupName) : result = doExport(exportPath, name, groupName = groupName) return result
def doShadeExport(): from tool.utils import entityInfo reload(entityInfo) asset = entityInfo.info() groupNames = ['Geo_Grp', 'Rig:Geo_Grp'] # name = '%s_Shade' % asset.name() name = asset.getRefNaming('shade', showExt=False) exportPath = asset.getPath('ref') for groupName in groupNames: if mc.objExists(groupName): result = doExport(exportPath, name, groupName=groupName) return result
def checkConfirm(geoGrp): shot = entityInfo.info() step = shot.department() attr = '%s.%s_confirm' % (geoGrp, step) if not step in ['layout', 'anim']: return True if not mc.objExists(attr): mc.addAttr(geoGrp, ln='%s_confirm' % step, at='bool') mc.setAttr(attr, e=True, keyable=True) stepConfirm = mc.getAttr(attr) if stepConfirm: return True
def publishWork(ar=True) : """ publish dress work """ logger.info('Publishing work ...') saveFile = mc.file(save=True, type='mayaAscii') logger.debug('file saved %s' % saveFile) asset = entityInfo.info() publishDir = asset.publishDir() publishFile = '%s/%s' % (publishDir, os.path.basename(saveFile)) logger.debug('copying file from %s to %s' % (saveFile, publishFile)) result = fileUtils.copy(saveFile, publishFile) logger.debug('publish complete') if ar : logger.debug('prepare to publihs AR from %s' % result) publishAR(result)
def cleanNamespace(ad): definition = mc.getAttr('%s.definition' % ad) namespace = mc.getAttr('%s.repNamespace' % ad) asset = entityInfo.info(definition) assetName = asset.name() currName = namespace for key in removeName: if key in currName: currName = currName.replace(key, '') if not currName == assetName: arName = ad adNamespace = ad.replace(currName, assetName) asm_utils.setARNamespace(arName, adNamespace) logger.info('Clean namespace %s -> %s' % (namespace, adNamespace))
def compareLoc(self, arg=None): mode = mc.radioCollection('%sCompare_RC' % self.win, q=True, sl=True) selObj = mc.ls(sl=True)[0] ref = mc.getAttr('%s.reference' % selObj) asset = entityInfo.info(ref) assetName = asset.name() if mode == 'Asset': abcLoc = sd_utils.getShotAssetAsmLocator(assetName) if mode == 'Shot': abcLoc = sd_utils.getShotAsmHero(assetName) rootLoc = sd_utils.getShotSetRootLoc(assetName) add, remove = sd_utils.compareLoc(rootLoc, abcLoc)
def build(arg=None): asset = entityInfo.info() locs = sd_utils.importAssetAsmLocator(asset) setGrp = mc.group(em=True, n='|set') objs = sd_utils.build(locs) rootLoc = locs[0] mc.parent(rootLoc, setGrp) strObjs = ('\n').join(objs) if objs: mc.confirmDialog(title='Warning', message='%s missing assets\n----------------\n%s' % (len(objs), strObjs), button=['OK']) else: mc.confirmDialog(title='Success', message='Build complete', button=['OK'])
def doImportABC() : title = 'Test ABC' asset = entityInfo.info() abcDir = asset.rigDataPath('abc') files = fileUtils.listFile(abcDir) namespace = asset.name() obj = 'Geo_Grp' if files : latestFile = files[-1] path = '%s/%s' % (abcDir, latestFile) print 'abc file %s' % path abcImport.importCacheAsset(namespace, path) print('Success', 'Apply cache complete') return True else : print('Error', 'No abc cache file. Contact Rig department') return False
def doImportABC(): title = 'Test ABC' asset = entityInfo.info() abcDir = asset.rigDataPath('abc') files = fileUtils.listFile(abcDir) namespace = asset.name() obj = 'Geo_Grp' if files: latestFile = files[-1] path = '%s/%s' % (abcDir, latestFile) print 'abc file %s' % path abcImport.importCacheAsset(namespace, path) print('Success', 'Apply cache complete') return True else: print('Error', 'No abc cache file. Contact Rig department') return False
def doImportVrayNodes(): # Get from Shade allRefs = mc.file(q=True, r=True) refPaths = [] for ref in allRefs: lod = pipelineTools.getFileTask(os.path.basename(ref)) refPath = os.path.dirname(ref) # instance asset.info asset = entityInfo.info('%s/_%s' % (refPath, lod)) dataPath = asset.getPath('refData') dataFile = asset.getRefNaming('vrayNodeData') dataFilePath = '%s/%s' % (dataPath, dataFile) if os.path.exists(dataFilePath): importVrayNodes(dataFilePath) print 'import vray node %s' % dataFilePath else: print 'Skip -> File not found %s' % dataFilePath
def publishAR(source) : """ publish AR from dress work """ logger.info('Publishing AR file ...') if os.path.exists(source) : asset = entityInfo.info() arFile = '%s/%s' % (asset.getPath('ref'), asset.getRefNaming('ar')) if os.path.exists(arFile) : logger.debug('File exists. Backing up %s' % arFile) backupResult = pipelineTools.backupRef(arFile) logger.debug('Backup complete %s' % backupResult) logger.debug('Copying %s to %s' % (source, arFile)) result = fileUtils.copy(source, arFile) logger.info('Publish complete') return result else : logger.warning('%s not exists. Publihsing stop.' % source)
def doImportVrayNodes() : # Get from Shade allRefs = mc.file(q = True, r = True) refPaths = [] for ref in allRefs : lod = pipelineTools.getFileTask(os.path.basename(ref)) refPath = os.path.dirname(ref) # instance asset.info asset = entityInfo.info('%s/_%s' % (refPath, lod)) dataPath = asset.getPath('refData') dataFile = asset.getRefNaming('vrayNodeData') dataFilePath = '%s/%s' % (dataPath, dataFile) if os.path.exists(dataFilePath) : importVrayNodes(dataFilePath) print 'import vray node %s' % dataFilePath else : print 'Skip -> File not found %s' % dataFilePath
def importAssetAsmLocator(asset=None): if not asset: asset = entityInfo.info() refPath = asset.getPath('ref') locPath = asset.getRefNaming('loc') refAbcFile = '%s/%s' % (refPath, locPath) if os.path.exists(refAbcFile): root = readAbc(str(refAbcFile)) setLoc = root[0] if not mc.objExists(setLoc) : abcUtils.importABC('',refAbcFile.replace('\\','/')) else: logger.warning('%s already exists. Skip import abc' % setLoc) mc.select(setLoc, hi=True) locs = mc.ls(sl=True, l=True) locs = [a for a in locs if mc.objExists('%s.reference' % a)] return locs
def locatorName(self, ad): if self.assetRoot == ad: assetDefinition = mc.getAttr('%s.definition' % ad) asset = entityInfo.info(assetDefinition) assetName = asset.name() return '%s_loc' % assetName adName = ad elements = ad.split(':') if len(elements) >= 2: adName = (':').join(elements[1:]) if adName[-1].isdigit(): adName = adName.replace(adName[-1], '_%s' % (adName[-1])) for key in self.removeName: if key in adName: adName = adName.replace(key, '') name = '%s_loc' % adName.replace(':', '_') return name
def data_file(self): shot = entityInfo.info() dataPath = shot.getShotData() step = shot.department() dataFile = '%s/%s' % (dataPath, 'cameraAsset_%s.yml' % step) return dataFile
def publishFile(self) : logger.debug('--- publishing ---') # publish file publishFile = self.svPublishFile workFile = self.asset.publishFile(showUser = True) workDir = self.asset.workDir() user = hook.getUser() self.setStatus('--- File Publish ---', True, [40, 40, 40], 0) if publishFile and workDir : saveFile = '%s/%s' % (workDir, os.path.basename(workFile)) # saveFile = hook.addUser(saveFile, user) # save file logger.debug('Saving file -> %s' % saveFile) saveResult = hook.save(saveFile, rename = False) logger.info('Save file done %s' % saveResult) self.setStatus('Save', saveResult) # get increment version thisFile = entityInfo.info() incrementFile = thisFile.nextVersion() # manage thumbnail / media self.manageMediaFile() # extra command batch = not self.ui.noBatch_checkBox.isChecked() refPath = self.asset.getPath('ref') logger.debug('Extra export -> %s' % refPath) extraResults = extra.publish(self.asset, batch, mainUI=self) if extraResults : for each in extraResults : title = each status = extraResults[each]['status'] message = extraResults[each]['message'] self.setStatus('%s' % title, status) logger.info('%s %s' % (title, message)) # copy publish logger.debug('Publish file from %s -> %s' % (saveResult, publishFile)) copyResult = fileUtils.copy(saveResult, publishFile) logger.info('Publish file to %s' % publishFile) self.setStatus('Published', copyResult) if saveResult : # set status logger.debug('Increment file -> %s' % incrementFile) # increment file # check increment override with root file fileToIncrement = str(self.ui.incrementFile_lineEdit.text()) incrementOverride = False if os.path.exists(fileToIncrement) and self.ui.incrementRoolFile_checkBox.isChecked() : incrementOverride = True if batch : if not incrementOverride : incrementResult = hook.save(incrementFile) # override increment else : increment = entityInfo.info(fileToIncrement) incrementFile = increment.nextVersion() incrementResult = fileUtils.copy(fileToIncrement, incrementFile) else : incrementResult = fileUtils.copy(saveResult, incrementFile) if incrementResult : self.setStatus('Increment File', incrementResult) logger.info('Increment file to %s' % incrementFile) return True
def __init__(self, parent=None): self.count = 0 #Setup Window super(MyForm, self).__init__(parent) self.mayaUI = 'matteImportWin' deleteUI(self.mayaUI) # read .ui directly loader = QtUiTools.QUiLoader() loader.setWorkingDirectory(moduleDir) f = QtCore.QFile("%s/matteImport_ui.ui" % moduleDir) f.open(QtCore.QFile.ReadOnly) self.myWidget = loader.load(f, self) self.ui = self.myWidget f.close() self.ui.show() self.ui.setWindowTitle('PT Vray Matte Import v.1.0') # variable self.asset = entityInfo.info() self.project = projectInfo.info() # project filters self.projectPrefix = ['Lego_', 'TVC_'] # char ID self.objectIDStep = 20 self.objectIDStart = 1000 self.objectIDRange = 20000 # prop ID self.propIDStep = 10 self.propIDStart = 100000 self.propIDRange = 110000 # icons self.logo = '%s/%s' % (moduleDir, 'icons/logo.png') self.logo2 = '%s/%s' % (moduleDir, 'icons/logo2.png') self.okIcon = '%s/%s' % (moduleDir, 'icons/ok_icon.png') self.xIcon = '%s/%s' % (moduleDir, 'icons/x_icon.png') self.rdyIcon = '%s/%s' % (moduleDir, 'icons/rdy_icon.png') self.redIcon = '%s/%s' % (moduleDir, 'icons/red2_icon.png') self.openStatus = 'Open ' self.assignStatus = 'Assigned ' self.duplicatedStatus = 'Duplicated ID' self.readyStatus = 'Ready' self.inDb = 'In DataBase' self.wrongIDStatus = 'Wrong ID Setting' self.extraPresetStatus = 'Extra Preset' # target rigGrp self.rigGrp = 'Rig_Grp' self.geoGrp = 'Geo_Grp' # table objectID self.statusCol = 0 self.assetCol = 1 self.noCol = 2 self.oIDCol = 3 self.mIDsCol = 4 self.pathCol = 5 # table colors self.red = [60, 0, 0] self.green = [0, 60, 0] self.blue = [20, 40, 100] self.lightGreen = [40, 100, 0] self.initFunctions() self.initSignals()
def exportVrayNode(dataFile, nodeFile): asset = entityInfo.info() data = dict() vrayDispData = dict() vrayPropData = dict() vrayDisps = mc.ls(type='VRayDisplacement') vrayProps = mc.ls(type='VRayObjectProperties') for each in vrayDisps: vdNode = str(each) members = mc.sets(each, q=True) members = [str(a) for a in members] vrayDispData.update({vdNode: members}) for each in vrayProps: vpNode = str(each) members = mc.sets(each, q=True) members = [str(a) for a in members] vrayPropData.update({vpNode: members}) data = { 'assetName': asset.name(), 'vrayDisp': vrayDispData, 'vrayProp': vrayPropData, 'nodeFile': str(nodeFile), 'assetPath': str(asset.getPath('ref')) } dirDataFile = os.path.dirname(dataFile) if not os.path.exists(dirDataFile): os.makedirs(dirDataFile) result1 = fileUtils.ymlDumper(dataFile, data) # ============================ # export nodes exp = 'exp' expNodes = vrayDisps + vrayProps expList = [] oriData = dict() result2 = None for each in expNodes: node = each tmpName = '%s_%s' % (node, exp) originalNode = mc.rename(node, tmpName) exportNode = mc.duplicate(tmpName, n=node) if exportNode: expList.append(exportNode[0]) if originalNode: oriData.update({originalNode: node}) if expList: mc.select(expList, ne=True) result2 = mc.file(nodeFile, force=True, options="v=0;", typ="mayaAscii", pr=True, es=True) # clean lock node cleanFile(result2) # delete if expList: mc.delete(expList) # rename back for each in oriData: mc.rename(each, oriData[each]) return dataFile, result2
def exportVrayNode(dataFile, nodeFile) : asset = entityInfo.info() data = dict() vrayDispData = dict() vrayPropData = dict() vrayDisps = mc.ls(type = 'VRayDisplacement') vrayProps = mc.ls(type = 'VRayObjectProperties') for each in vrayDisps : vdNode = str(each) members = mc.sets(each, q = True) members = [str(a) for a in members] vrayDispData.update({vdNode: members}) for each in vrayProps : vpNode = str(each) members = mc.sets(each, q = True) members = [str(a) for a in members] vrayPropData.update({vpNode: members}) data = {'assetName': asset.name(), 'vrayDisp': vrayDispData, 'vrayProp': vrayPropData, 'nodeFile': str(nodeFile), 'assetPath': str(asset.getPath('ref'))} dirDataFile = os.path.dirname(dataFile) if not os.path.exists(dirDataFile) : os.makedirs(dirDataFile) result1 = fileUtils.ymlDumper(dataFile, data) # ============================ # export nodes exp = 'exp' expNodes = vrayDisps + vrayProps expList = [] oriData = dict() result2 = None for each in expNodes : node = each tmpName = '%s_%s' % (node, exp) originalNode = mc.rename(node, tmpName) exportNode = mc.duplicate(tmpName, n = node) if exportNode : expList.append(exportNode[0]) if originalNode : oriData.update({originalNode: node}) if expList : mc.select(expList, ne = True) result2 = mc.file(nodeFile, force = True, options = "v=0;", typ = "mayaAscii", pr = True, es = True) # clean lock node cleanFile(result2) # delete if expList : mc.delete(expList) # rename back for each in oriData : mc.rename(each, oriData[each]) return dataFile, result2
def __init__(self, parent=None): self.count = 0 #Setup Window super(MyForm, self).__init__(parent) self.mayaUI = 'matteExportWin' deleteUI(self.mayaUI) # read .ui directly loader = QtUiTools.QUiLoader() loader.setWorkingDirectory(moduleDir) f = QtCore.QFile("%s/matteExport_ui.ui" % moduleDir) f.open(QtCore.QFile.ReadOnly) self.myWidget = loader.load(f, self) self.ui = self.myWidget f.close() self.ui.show() self.ui.setWindowTitle('PT Vray Matte Export v.1.2') # variable self.asset = entityInfo.info() self.project = projectInfo.info() # project filters self.projectPrefix = ['Lego_', 'TVC_', 'Maya'] # char ID self.objectIDStep = 20 self.objectIDStart = 1000 self.objectIDRange = 20000 # prop ID self.propIDStep = 10 self.propIDStart = 100000 self.propIDRange = 110000 # icons self.logo = '%s/%s' % (moduleDir, 'icons/logo.png') self.logo2 = '%s/%s' % (moduleDir, 'icons/logo2.png') self.okIcon = '%s/%s' % (moduleDir, 'icons/ok_icon.png') self.xIcon = '%s/%s' % (moduleDir, 'icons/x_icon.png') self.rdyIcon = '%s/%s' % (moduleDir, 'icons/rdy_icon.png') self.redIcon = '%s/%s' % (moduleDir, 'icons/red2_icon.png') self.openStatus = 'Open ' self.assignStatus = 'Assigned ' self.duplicatedStatus = 'Duplicated ID' self.readyStatus = 'Ready' self.inDb = 'In DataBase' self.wrongIDStatus = 'Wrong ID Setting' self.extraPresetStatus = 'Extra Preset' # target rigGrp self.rigGrp = ['Rig_Grp', 'Rig:Rig_Grp'] # matte presets self.charPresetPath = 'P:/Library/lookdev/mattePresets/charPreset' self.propPresetPath = 'P:/Library/lookdev/mattePresets/propPreset' self.presetData = dict() # table objectID self.idCol = 0 self.oIDCol = 1 self.assetNameCol = 2 self.assetPathCol = 3 self.userCol = 4 self.mIDsCol = 5 # table material list self.vrayMtlCol = 0 self.oID2Col = 1 self.tagCol = 2 self.statusCol = 3 self.MultiMatteCol = 4 self.colorCol = 5 # table colors self.red = [60, 0, 0] self.green = [0, 60, 0] self.blue = [20, 40, 100] self.lightGreen = [40, 100, 0] self.colorMap = {'red': [100, 0, 0], 'green': [0, 100, 0], 'blue': [0, 0, 100], None: [0, 0, 0]} self.initFunctions() self.initSignals()
def __init__(self, parent=None): self.count = 0 #Setup Window super(MyForm, self).__init__(parent) # QtGui.QWidget.__init__(self, parent) self.ui = ui.Ui_AlembicImportWin() self.ui.setupUi(self) # hook.logger.setLogFile(logPath, True) # hook.logger.setLevel('INFO') # hook.logger.setLogName(scriptName) # set version self.setWindowTitle('PT Alembic Cache Import v.1.0') # icons self.logo = '%s/%s' % (os.path.dirname(moduleDir), 'icons/logo.png') self.logo2 = '%s/%s' % (os.path.dirname(moduleDir), 'icons/alembic_logo.png') self.okIcon = '%s/%s' % (os.path.dirname(moduleDir), 'icons/ok_icon.png') self.xIcon = '%s/%s' % (os.path.dirname(moduleDir), 'icons/x_icon.png') self.rdyIcon = '%s/%s' % (os.path.dirname(moduleDir), 'icons/rdy_icon.png') self.ipIcon = '%s/%s' % (os.path.dirname(moduleDir), 'icons/ip_icon.png') self.refreshIcon = '%s/%s' % (os.path.dirname(moduleDir), 'icons/refresh_icon.png') self.infoIcon = '%s/%s' % (os.path.dirname(moduleDir), 'icons/info_icon.png') self.abcIcon = '%s/%s' % (os.path.dirname(moduleDir), 'icons/abc_icon.png') self.refIcon = '%s/%s' % (os.path.dirname(moduleDir), 'icons/ref_icon.png') self.iconSize = 15 # group self.cacheGrp = 'Geo_Grp' self.assetInfo = dict() self.cacheAssetTypeList = ['character', 'prop', 'animal'] self.normalAsset = '[asset]' self.nonCacheAsset = 'exportGrp' # table column self.cacheListCol = 0 self.inSceneCol = 1 self.lodCol = 2 self.currentVersionCol = 3 self.publishVersionCol = 4 self.statusCol = 5 self.assetPathCol = 6 self.cacheGrpCol = 7 self.shadeCol = 8 self.hierarchyCol = 9 self.nonCacheListCol = 0 self.nonCahceInSceneCol = 1 # instance projectInfo self.projectInfo = projectInfo.info() self.shotInfo = entityInfo.info() self.setting = None self.cacheData = None self.defaultAssetLevel = 'Cache' self.cacheAssetInfo = dict() # shot variable self.project = None self.episode = None self.sequence = None self.shot = None self.step = None self.dept = 'light' # path self.animCurvePath = None # start functions self.initSignal() self.initData()
def setName(self): asset = entityInfo.info() date = str(datetime.now()).split(' ')[0].replace('-', '_') setName = '%s%s_%s_fixSet' % (asset.department(), asset.taskLOD().capitalize(), date) return setName
def setUI(self): asset = entityInfo.info() self.ui.asset_label.setText(asset.name()) self.ui.department_label.setText(asset.department()) self.ui.lod_label.setText(asset.taskLOD())
def __init__(self, parent=None): self.count = 0 #Setup Window super(MyForm, self).__init__(parent) self.mayaUI = 'dbViewerWindow' deleteUI(self.mayaUI) # read .ui directly loader = QtUiTools.QUiLoader() loader.setWorkingDirectory(moduleDir) f = QtCore.QFile("%s/dbViewer.ui" % moduleDir) f.open(QtCore.QFile.ReadOnly) self.myWidget = loader.load(f, self) self.ui = self.myWidget f.close() self.ui.show() self.ui.setWindowTitle('PT Matte Viewer') # variable self.asset = entityInfo.info() self.project = projectInfo.info() # project filters self.projectPrefix = ['Lego_', 'TVC_'] self.objectIDStep = 20 self.objectIDStart = 100 self.objectIDRange = 20000 # icons self.logo = '%s/%s' % (moduleDir, 'icons/logo.png') self.logo2 = '%s/%s' % (moduleDir, 'icons/shotgun_logo.png') self.okIcon = '%s/%s' % (moduleDir, 'icons/ok_icon.png') self.xIcon = '%s/%s' % (moduleDir, 'icons/x_icon.png') self.rdyIcon = '%s/%s' % (moduleDir, 'icons/rdy_icon.png') # table objectID self.idCol = 0 self.oIDCol = 1 self.assetNameCol = 2 self.assetPathCol = 3 self.userCol = 4 self.mIDsCol = 5 # table matteID self.umidCol = 0 self.midCol = 1 self.colorCol = 2 self.multiMatteCol = 3 self.vrayMtlCol = 4 # color self.dbColor = [0, 20, 60] self.presetColor = [0, 20, 100] self.initFunctions() self.initSignals()
def massRefRlps_submit_onClick(self, *args): print( 'DEBUG : massRefRlps_UI|massRefRlps_submit_onClick : >>> function start <<<' ) allrefDict = self._allRef_NS_.copy() RN_name = [] SelectedItem = cmds.textScrollList('textScrollList_allLists', q=True, si=True) selectedFile = cmds.ls(sl=True, l=True) if len(SelectedItem) > 0: RN_name = SelectedItem elif len(selectedFile) > 0: for obj in selectedFile[:]: if '_loc' in obj.split('|')[-1] or cmds.referenceQuery( obj, isNodeReferenced=True) is False: selectedFile.remove(obj) print( 'DEBUG : massRefRlps_UI|massRefRlps_submit_onClick : !! REMOVE \'' + obj + '\' !!') else: RN_name.append(cmds.referenceQuery(obj, referenceNode=True)) else: cmds.error('Nothing select !!') #Create progress bar window ------------ if cmds.window('masRefReplace_progressBar_win', ex=True): cmds.deleteUI('masRefReplace_progressBar_win') cmds.window('masRefReplace_progressBar_win') cmds.columnLayout(adj=True) progressControl = cmds.progressBar('masRefReplace_progressBar_replace', maxValue=10, width=300) cmds.showWindow('masRefReplace_progressBar_win') print('DEBUG : massRefRlps_UI|get_allRef : Progressbar window Create.') #---------------------------------------- #Get dest Path destPath = cmds.textFieldGrp('textFieldGrp_RefPath', q=True, text=True) if not os.path.exists(destPath): cmds.deleteUI('masRefReplace_progressBar_win') cmds.error('new path file doensn\'t exists.') count = len(RN_name) #Edit progress bar cmds.progressBar('masRefReplace_progressBar_replace', edit=True, beginProgress=True, isInterruptable=True, status='"Example Calculation ...', maxValue=len(RN_name)) print('>>>>>>>>>>>> START REPLACEMENT <<<<<<<<<<<<') replacedNode = [] for i in range(count): RN_nodeName = RN_name[i] if RN_nodeName not in replacedNode and os.path.exists(destPath): newPath = cmds.file(destPath, loadReference=RN_nodeName, options="v=0", f=True) # rename namespace if is_importEntityInfo: new_namespace = entityInfo.info(destPath).name() cmds.file(destPath, e=True, namespace=new_namespace) #rename reference node cmds.lockNode(RN_nodeName, l=False) rename_result = cmds.rename(RN_nodeName, new_namespace + 'RN') cmds.lockNode(rename_result, l=True) print(' Old reference node ') print(' object : ' + RN_name[i]) print(' RFnode : ' + RN_nodeName) print(' replace with ') print(' objectNS : ' + cmds.file(newPath, q=True, namespace=True) + ':') print(' path : ' + newPath + '\n ........................................') replacedNode.append(RN_nodeName) cmds.progressBar('masRefReplace_progressBar_replace', edit=True, step=1) else: if not os.path.exists(RN_nodeName): print(RN_nodeName + ' is not exists!!!') else: print(destPath + ' is not exists!!!') cmds.progressBar('masRefReplace_progressBar_replace', edit=True, step=1) #print count count += 1 cmds.progressBar('masRefReplace_progressBar_replace', edit=True, endProgress=True) cmds.deleteUI('masRefReplace_progressBar_win') self.refreshIcon_onclick() print('=============== Process End ===============')