def doConnectShade(self) : title = 'connect shade' asset = entityInfo.info() edlPath = asset.dataPath(asset.uv, '%s_%s' % (asset.uv, asset.taskLOD()), data = 'edl') shadePath = asset.dataPath(asset.uv, '%s_%s' % (asset.uv, asset.taskLOD()), data = 'shadeFile') shadeFile = str() edlFile = str() edlFiles = sorted(fileUtils.listFile(edlPath)) if edlFiles : edlFile = '%s/%s' % (edlPath, edlFiles[-1]) shadeFiles = sorted(fileUtils.listFile(shadePath)) if shadeFiles : shadeFile = '%s/%s' % (shadePath, shadeFiles[-1]) if edlFile and shadeFile : namespace = 'Rig' result = pipelineTools.assignShader(shadeFile, edlFile, namespace) self.setStatus(title, True) else : self.messageBox('Error', 'No edl file')
def doConnectShade(self): title = 'connect shade' asset = entityInfo.info() edlPath = asset.dataPath(asset.uv, '%s_%s' % (asset.uv, asset.taskLOD()), data='edl') shadePath = asset.dataPath(asset.uv, '%s_%s' % (asset.uv, asset.taskLOD()), data='shadeFile') shadeFile = str() edlFile = str() edlFiles = sorted(fileUtils.listFile(edlPath)) if edlFiles: edlFile = '%s/%s' % (edlPath, edlFiles[-1]) shadeFiles = sorted(fileUtils.listFile(shadePath)) if shadeFiles: shadeFile = '%s/%s' % (shadePath, shadeFiles[-1]) if edlFile and shadeFile: namespace = 'Rig' result = pipelineTools.assignShader(shadeFile, edlFile, namespace) self.setStatus(title, True) else: self.messageBox('Error', 'No edl file')
def setLodComboBox(self) : data = self.cacheData lods = [] if data : for each in data : assetName = each assetPath = data[each]['assetPath'] assetDir = os.path.dirname(assetPath) files = fileUtils.listFile(assetDir) for eachFile in files : lod = eachFile.split('_')[-1] if not lod in lods : lods.append(lod) self.ui.assetVersion_comboBox.addItems(lods) # set default # remove this line, if using data default = 'Cache.mb' if default in lods : index = lods.index(default) self.ui.assetVersion_comboBox.setCurrentIndex(index)
def assign() : asset = entityInfo.info() dataPath = '%s/data' % asset.getPath('uv', 'uv_%s' % asset.taskLOD()) edlUVPath = '%s/%s' % (dataPath, 'edl') shadeFilePath = '%s/%s' % (dataPath, 'shadeFile') dataFiles = sorted(fileUtils.listFile(edlUVPath)) shadeFiles = sorted(fileUtils.listFile(shadeFilePath)) namespace = 'Rig' if shadeFiles and dataFiles : shadeFile = '%s/%s' % (shadeFilePath, shadeFiles[-1]) edlFile = '%s/%s' % (edlUVPath, dataFiles[-1]) if os.path.exists(shadeFile) and os.path.exists(edlFile) : assignShader(shadeFile, edlFile, namespace)
def collectCacheVersion(self) : versions = [] if self.setting : cachePath = self.setting['cachePath'] cacheInfo = dict() if os.path.exists(cachePath) : versions = fileUtils.listFolder(cachePath) for version in versions : files = fileUtils.listFile(os.path.join(cachePath, version)) assetNames = [os.path.splitext(a)[0] for a in files] i = 0 for eachFile in assetNames : assetName = eachFile if not assetName in cacheInfo.keys() : cacheInfo.update({assetName: {'versions': [version], 'versionKey': {version: os.path.join(cachePath, version, files[i])}}}) else : cacheInfo[assetName]['versions'].append(version) cacheInfo[assetName]['versionKey'].update({version: os.path.join(cachePath, version, files[i])}) i += 1 return cacheInfo
def browseBase(self): bases = fileUtils.listFile(self.headBase) self.ui.base_comboBox.clear() for each in bases: self.ui.base_comboBox.addItem(each)
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 assign(): asset = entityInfo.info() dataPath = '%s/data' % asset.getPath('uv', 'uv_%s' % asset.taskLOD()) edlUVPath = '%s/%s' % (dataPath, 'edl') shadeFilePath = '%s/%s' % (dataPath, 'shadeFile') dataFiles = sorted(fileUtils.listFile(edlUVPath)) shadeFiles = sorted(fileUtils.listFile(shadeFilePath)) namespace = 'Rig' if shadeFiles and dataFiles: shadeFile = '%s/%s' % (shadeFilePath, shadeFiles[-1]) edlFile = '%s/%s' % (edlUVPath, dataFiles[-1]) if os.path.exists(shadeFile) and os.path.exists(edlFile): assignShader(shadeFile, edlFile, namespace)
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 saveStill(mediaType='still', ext=False): asset = entityInfo.info() # save to surface mediaDir = asset.surfaceOutput(mediaType) currentFile = asset.fileName(ext=False) files = fileUtils.listFile(mediaDir) fileName = '%s_%02d' % (currentFile, 1) if files: fileCount = 0 for each in files: if currentFile in each: fileCount += 1 fileName = '%s_%02d' % (currentFile, fileCount + 1) # save to surface result = saveVrayRender(mediaDir, fileName, img='jpg') print 'Saved to %s' % result if result: src = '%s.jpg' % result if os.path.exists(src): # save to hero heroDir = asset.mediaHeroName(mediaType=mediaType, returnPath=True) dst = '%s.jpg' % heroDir result2 = fileUtils.copy(src, dst) print 'Saved to %s' % result2 return src
def browseBase(self) : bases = fileUtils.listFile(self.headBase) self.ui.base_comboBox.clear() for each in bases : self.ui.base_comboBox.addItem(each)
def doSyncHData(self) : title = 'sync HData' asset = entityInfo.info() hDir = asset.rigDataPath('hdata') files = fileUtils.listFile(hDir) node = 'Geo_Grp' if files : latestFile = files[-1] path = '%s/%s' % (hDir, latestFile) print 'Hdata file %s' % path pipelineTools.applyHierarchyData(node, path) result = pipelineTools.removeExcessiveGeo(node, path) print 'Done' if result : self.messageBox('Warning', 'Excessive geometries') print result self.setStatus('%s - Excessive geometries' % title, True) else : self.messageBox('Success', 'Sync hierarchy complete') self.setStatus('%s' % title, True) else : self.messageBox('Error', 'No H-Data. Contact Rig department') self.setStatus('%s - No H-Data' % title, False)
def checkElements() : missing = [] info = dict() for each in elements : dir = '%s/%s/%s' % (path, res, each) if os.path.exists(dir) : files = fileUtils.listFile(dir) heroFrame = '' for eachFile in files : num = findNum(eachFile) if num : if startImg == int(num) : heroFrame = eachFile if heroFrame : info[each] = {'filename': heroFrame, 'path': '%s/%s' % (dir, heroFrame)} if not heroFrame : missing.append(each) if missing : for each in missing : print 'missing file in dir %s' % each print '==============' print '%s dir' % len(missing) return info, missing
def doSyncHData(self): title = 'sync HData' asset = entityInfo.info() hDir = asset.rigDataPath('hdata') files = fileUtils.listFile(hDir) node = 'Geo_Grp' if files: latestFile = files[-1] path = '%s/%s' % (hDir, latestFile) print 'Hdata file %s' % path pipelineTools.applyHierarchyData(node, path) result = pipelineTools.removeExcessiveGeo(node, path) print 'Done' if result: self.messageBox('Warning', 'Excessive geometries') print result self.setStatus('%s - Excessive geometries' % title, True) else: self.messageBox('Success', 'Sync hierarchy complete') self.setStatus('%s' % title, True) else: self.messageBox('Error', 'No H-Data. Contact Rig department') self.setStatus('%s - No H-Data' % title, False)
def search(self): self.ui.copyListWidget.clear() path = str(self.ui.pathLineEdit.text()) txt = str(self.ui.searchLineEdit.text()) copylist = fileUtils.listFile(path) for copy in copylist: if txt in copy: self.ui.copyListWidget.addItem(copy)
def listRefFiles(self) : refPath = self.asset.getPath('ref') files = fileUtils.listFile(refPath) listWidget = 'ref_listWidget' iconPath = self.mayaIcon color = [0, 0, 0] self.ui.ref_listWidget.clear() for eachFile in files : self.addListWidgetItem(listWidget, eachFile, iconPath, color, 1)
def getShotAsmVersion(assetName) : abcHero = getShotAsmHero(assetName) abcDir = os.path.dirname(abcHero) abcVersions = fileUtils.listFile(abcDir) abcVersions = ['%s/%s' % (abcDir, a) for a in abcVersions] if abcHero in abcVersions : abcVersion = abcVersions.remove(abcHero) return abcVersions
def listPublishFiles(self) : publishDir = self.asset.publishDir() files = fileUtils.listFile(publishDir, 'ma') listWidget = 'publish_listWidget' iconPath = self.mayaIcon color = [0, 0, 0] self.ui.publish_listWidget.clear() for eachFile in files : self.addListWidgetItem(listWidget, eachFile, iconPath, color, 1)
def setPresetFiles(self) : if self.charPreset : path = self.charPresetPath if self.propPreset : path = self.propPresetPath files = fileUtils.listFile(path, 'txt') if files : self.ui.preset_comboBox.clear() self.ui.preset_comboBox.addItems(files)
def getFileSequences(fileName) : dir = os.path.dirname(fileName) files = fileUtils.listFile(dir) sequences = [] pos = findNum(fileName, True) fileName[-pos[-1] - 1: -pos[0]] for each in files : num = each[-pos[-1] - 1: -pos[0]] if num.isdigit() : sequences.append('%s/%s' % (dir, each)) return sequences
def listWorkAreaUI(self): path = str(self.ui.path_lineEdit.text()) rigPath = '%s/rig/maya/work' % (path) workFiles = fileUtils.listFile(rigPath) self.texturePath = '%s/textures' % (path) self.ui.work_listWidget.clear() for each in workFiles: self.ui.work_listWidget.addItem(each) self.setRes(self.texturePath) if os.path.exists(rigPath): self.ui.open_pushButton.setEnabled(True) self.ui.save_pushButton.setEnabled(True)
def listWorkAreaUI(self) : path = str(self.ui.path_lineEdit.text()) rigPath = '%s/rig/maya/work' % (path) workFiles = fileUtils.listFile(rigPath) self.texturePath = '%s/textures' % (path) self.ui.work_listWidget.clear() for each in workFiles : self.ui.work_listWidget.addItem(each) self.setRes(self.texturePath) if os.path.exists(rigPath) : self.ui.open_pushButton.setEnabled(True) self.ui.save_pushButton.setEnabled(True)
def listCopy(self): self.ui.copyListWidget.clear() copylist = [] user = str(self.ui.userLineEdit.text()) path = str(self.ui.pathLineEdit.text()) copylist = fileUtils.listFile(path) verlist = [ int(n.split('_')[-1].split('.')[0]) for n in copylist if n.split('_')[-1].split('.')[0].isdigit() ] verlist.sort() version = verlist[-1] + 1 logName = '%s_asm_%03d' % (user, version) self.ui.copyListWidget.addItems(copylist) self.ui.filenameLineEdit.setText(logName)
def doTestABC(self) : title = 'Test ABC' asset = entityInfo.info() abcDir = asset.rigDataPath('abc') files = fileUtils.listFile(abcDir) obj = 'Geo_Grp' if files : latestFile = files[-1] path = '%s/%s' % (abcDir, latestFile) print 'abc file %s' % path abcUtils.importABC(obj, path, mode = 'add') self.messageBox('Success', 'Apply cache complete') self.setStatus(title, True) else : self.messageBox('Error', 'No abc cache file. Contact Rig department') self.setStatus(title, False)
def __init__(self, parent=None): self.count = 0 #Setup Window super(MyForm, self).__init__(parent) self.mayaUI = 'shadeToolWin' deleteUI(self.mayaUI) # read .ui directly loader = QtUiTools.QUiLoader() loader.setWorkingDirectory(moduleDir) f = QtCore.QFile("%s/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 Shade Tool v.1.0') # =============================================== # icons self.okIcon = '%s/icons/%s' % (moduleDir, 'ok_icon.png') self.xIcon = '%s/icons/%s' % (moduleDir, 'x_icon.png') # variable self.lookDevPresetPath = "P:/Library/studioPresets/lookdev/VRaySettingsNodePreset/VRaySettingsNodePreset_lookdev.mel" self.lightRig = 'P:/Library/studioPresets/lookdev/lightRig' self.turnTableCamera = 'P:/Library/studioPresets/lighting/default/camera/TT.ma' self.lineup = 'P:/Library/studioPresets/lookdev/lineup/frd_lineup.ma' self.lightRigFiles = sorted(fileUtils.listFile(self.lightRig)) self.selLightPath = str() self.setUI() self.initSignals()
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 doTestABC(self): title = 'Test ABC' asset = entityInfo.info() abcDir = asset.rigDataPath('abc') files = fileUtils.listFile(abcDir) obj = 'Geo_Grp' if files: latestFile = files[-1] path = '%s/%s' % (abcDir, latestFile) print 'abc file %s' % path abcUtils.importABC(obj, path, mode='add') self.messageBox('Success', 'Apply cache complete') self.setStatus(title, True) else: self.messageBox('Error', 'No abc cache file. Contact Rig department') self.setStatus(title, False)
def findVersion(self, path, nameKey): files = fileUtils.listFile(path) versions = [] for each in files: if nameKey in each: eles = each.split('_') for eachEle in eles: if eachEle[0] == 'v' and eachEle[1:].isdigit(): version = eachEle[1:] versions.append(int(version)) if versions: newVersion = 'v%03d' % (versions[-1] + 1) else: newVersion = 'v001' return newVersion # import sys # sys.path.append('O:/studioTools/maya/python') # from tool.rig.facialTexture import facialTexture_app as app # reload(app) # app.path = 'P:/Lego_Frozen/asset/3D/character/main/frz_anna/textures' # app.res = '4K' # app.clear('all') # app.makeRenderFacial() # app.makeAnimFacial(app.renderLayerTextureName) # app.rigFacialCtrl()
def findVersion(self, path, nameKey) : files = fileUtils.listFile(path) versions = [] for each in files : if nameKey in each : eles = each.split('_') for eachEle in eles : if eachEle[0] == 'v' and eachEle[1:].isdigit() : version = eachEle[1:] versions.append(int(version)) if versions : newVersion = 'v%03d' % (versions[-1] + 1) else : newVersion = 'v001' return newVersion # import sys # sys.path.append('O:/studioTools/maya/python') # from tool.rig.facialTexture import facialTexture_app as app # reload(app) # app.path = 'P:/Lego_Frozen/asset/3D/character/main/frz_anna/textures' # app.res = '4K' # app.clear('all') # app.makeRenderFacial() # app.makeAnimFacial(app.renderLayerTextureName) # app.rigFacialCtrl()
def listWorkFileUI(self) : # clear UI self.ui.work_listWidget.clear() # mode work = self.ui.work_radioButton.isChecked() publish = self.ui.publish_radioButton.isChecked() sourceFile = self.ui.source_radioButton.isChecked() self.publishFileMap = dict() listWidget = 'work_listWidget' if work : # hide new button self.ui.new_pushButton.setEnabled(True) path = str(self.ui.path_lineEdit.text()) # workArea = str(self.ui.work_comboBox.currentText()) files = fileUtils.listFile(path) self.listFileListWidget(listWidget, files) if publish : # hide new button self.ui.new_pushButton.setEnabled(False) self.ui.open_pushButton.setText('Open As') step = self.stepMap[str(self.ui.step_comboBox.currentText())] task = self.getSelTask() key = '%s-%s' % (step, task) colorMap = [[20, 0, 0], [0, 20, 0], [0, 0, 20]] colorMap = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] i = 0 for each in setting.publishMap : keyList = setting.publishMap[each] displayList = [] colorShift = colorMap[i%3] if key in keyList : for eachKey in keyList : eStep = eachKey.split('-')[0] eTask = eachKey.split('-')[-1] publishDir = self.asset.publishDir(eStep, eTask) displayList.append('== %s ==' % eachKey) filenames = [] if os.path.exists(publishDir) : files = fileUtils.listFile(publishDir, 'ma') # filenames = [os.path.basename(a) for a in files] displayList = displayList + files for eachFile in files : self.publishFileMap.update({eachFile: '%s/%s' % (publishDir, eachFile)}) if not filenames : displayList.append('No File') self.listFileListWidget(listWidget, displayList, colorShift = colorShift) i += 1 if sourceFile : # hide new button self.ui.new_pushButton.setEnabled(False) self.showSourceFile()
def copy(self): path = str(self.ui.pathLineEdit.text()) user = str(self.ui.userLineEdit.text()) copylist = fileUtils.listFile(path) verlist = [ int(n.split('_')[-1].split('.')[0]) for n in copylist if n.split('_')[-1].split('.')[0].isdigit() ] verlist.sort() version = verlist[-1] + 1 if not self.ui.overrideCheckBox.isChecked(): logPath = '%s/%s_asm_%03d.db' % (path, user, version) if self.ui.overrideCheckBox.isChecked(): filename = str(self.ui.filenameLineEdit.text()) logPath = '%s/%s.db' % (path, filename) logPath = logPath.replace('\\', '/') # print logPath sel = mc.ls(sl=True, type='assemblyReference') allAR = dict() # print sel for ar in sel: if ':' in ar: arParent = ar.split('_NS')[0] if not allAR.has_key(arParent): path = mc.getAttr('%s.definition' % arParent) t = list(mc.getAttr('%s.t' % arParent)[0]) r = list(mc.getAttr('%s.r' % arParent)[0]) s = list(mc.getAttr('%s.s' % arParent)[0]) allAR[arParent] = { 'definition': path, 't': t, 'r': r, 's': s, 'type': 'parent' } path = mc.getAttr('%s.definition' % ar) t = list(mc.getAttr('%s.t' % ar)[0]) r = list(mc.getAttr('%s.r' % ar)[0]) s = list(mc.getAttr('%s.s' % ar)[0]) if not allAR[arParent].has_key('child'): allAR[arParent]['child'] = dict() allAR[arParent]['child'][ar] = { 'definition': path, 't': t, 'r': r, 's': s } else: path = mc.getAttr('%s.definition' % ar) t = list(mc.getAttr('%s.t' % ar)[0]) r = list(mc.getAttr('%s.r' % ar)[0]) s = list(mc.getAttr('%s.s' % ar)[0]) allAR[ar] = { 'definition': path, 't': t, 'r': r, 's': s, 'type': 'child' } fileUtils.ymlDumper(logPath, allAR) if os.path.exists(logPath): self.listCopy()