def bs_getAllFileTexturePathIfValid(): """ @ query all file texture path and, @ return if all are coming from same valid path. Returns: sourceimages directory (str). """ # get env details and sourceimage directory. envRoot = bs_pathGenerator.bs_getEnvDetails()['rootPath'] assetDept, assetType, assetName, uid = bs_pathGenerator.bs_getAssetDetails( ) sourceImageDir = bs_pathGenerator.bs_getAssetDir( astType=assetType, astDept=assetDept, astName=assetName)['dept'] + 'sourceimages/' allFileTextures = pm.ls(type='file') validPath = list() invalidPath = list() for each in allFileTextures: ftn = each.ftn.get() filtSourceImageDir = sourceImageDir.replace(envRoot, '') if ftn.find(filtSourceImageDir) != -1: validPath.append(each) else: invalidPath.append(each) if not invalidPath: return sourceImageDir bs_qui.bs_displayMessage('error', 'all path not from same path..') return False
def bs_checkAllFileTexturePathIsComingFromEnv(): """ @ check all file texture path is coming from environment. @ run this function if all path are same. Returns: bool. """ # get env details and sourceimage directory. envRoot = bs_pathGenerator.bs_getEnvDetails()['rootPath'] assetDept, assetType, assetName, uid = bs_pathGenerator.bs_getAssetDetails( ) sourceImageDir = bs_pathGenerator.bs_getAssetDir( astType=assetType, astDept=assetDept, astName=assetName)['dept'] + 'sourceimages/' sourceImageEnvDir = None notEnvPath = list() allFileTextures = pm.ls(type='file') for each in allFileTextures: ftn = each.ftn.get() if ftn.find('$') != -1: sourceImageEnvDir = '$BSW_PROD_SERVER/' + sourceImageDir.replace( envRoot, '') if sourceImageEnvDir: for each in allFileTextures: ftn = each.ftn.get() filtSourceImageDir = sourceImageEnvDir if not ftn.find(filtSourceImageDir) != -1: notEnvPath.append(each) if notEnvPath: return False return sourceImageEnvDir
def bs_makeGpuMayaFile(): """ @ make gpu maya file. Returns: """ # Make Gpu File # query current set. dept, assetType, assetName, uid = bs_pathGenerator.bs_getAssetDetails() if dept == 'Not Exist' or assetType == 'Not Exist' or assetName == 'Not Exist': bs_qui.bs_displayMessage('error', 'No Set Found in Scene.....') return False # get asset grade in current scene geoGrp = pm.PyNode('geo') assetGrade = geoGrp.assetGrade.get() # create file path. cacheDir = bs_pathGenerator.bs_getAssetDir( astType=assetType, astName=assetName, astDept=dept)['dept'] + 'gpu/' fileName = bs_pathGenerator.bs_getMainFileName().split('.')[0][:-3] + 'gpu' # check gpu maya file is exist or not. filePath = cacheDir + fileName + '.ma' if os.path.isfile(cacheDir + fileName + '.ma'): return True bs_runner.bs_blast(astPath=filePath, astName=assetName, astGrade=assetGrade, astUID=uid)
def addShaderPathInLineEdit(self): assetCategory, assetType, assetName, uid = bs_pathGenerator.bs_getAssetDetails( ) if assetType == 'Not Exist' or assetName == 'Not Exist': self.bstm_exportPath_le.setText('asset not found in scene.') return False deptDir = bs_pathGenerator.bs_getAssetDir(astType=assetType, astDept='Texture', astName=assetName)['dept'] shaderFileName = bs_pathGenerator.bs_getMainFileName().replace( '_tex.', '_shd.') if os.path.isfile(deptDir + 'shaders/' + shaderFileName): self.bstm_exportPath_le.setText(deptDir + 'shaders/' + shaderFileName) else: self.bstm_exportPath_le.setText('shaders not found')
def importShaders(self): # get shader directory. assetCategory, assetType, assetName, uid = bs_pathGenerator.bs_getAssetDetails( ) deptDir = bs_pathGenerator.bs_getAssetDir(astType=assetType, astDept='Texture', astName=assetName)['dept'] if not os.path.isdir(deptDir + 'shaders'): os.makedirs(deptDir + 'shaders') shaderDir = deptDir + 'shaders/' shaderFileName = bs_pathGenerator.bs_getMainFileName().replace( '_tex.', '_shd.') jsonFileName = bs_pathGenerator.bs_getMainFileName().replace( '_tex.ma', '_shd.json') bs_shadingEngine.bs_importShaders(shaderDir + shaderFileName, shaderDir + jsonFileName) self.refresh()
def addGpuPath(self): # query current set. dept, assetType, assetName, uid = bs_pathGenerator.bs_getAssetDetails() if dept == 'Not Exist' or assetType == 'Not Exist' or assetName == 'Not Exist': bs_qui.bs_displayMessage('error', 'No Set Found in Scene.....') return False cacheDir = bs_pathGenerator.bs_getAssetDir( astType=assetType, astName=assetName, astDept=dept)['dept'] + 'gpu/' fileName = bs_pathGenerator.bs_getMainFileName().split( '.')[0][:-3] + 'gpu' if os.path.isfile(cacheDir + fileName + '.ma'): self.bssm_GPUfilePath_LE.setText(cacheDir + fileName + '.ma') else: self.bssm_GPUfilePath_LE.setText('gpu maya file is not found...') if os.path.isfile(cacheDir + fileName + '.abc'): self.bssm_GPUcachePath_LE.setText(cacheDir + fileName + '.abc') else: self.bssm_GPUcachePath_LE.setText('gpu cache file is not found...')
def bs_makeGpuCacheFile(): """ @ make a gpu cache file and if gpu maya file is not exist then auto run bs_makeGpuMayaFile method. Returns: None. """ # query current set. dept, assetType, assetName, uid = bs_pathGenerator.bs_getAssetDetails() if dept == 'Not Exist' or assetType == 'Not Exist' or assetName == 'Not Exist': bs_qui.bs_displayMessage('error', 'No Set Found in Scene.....') return False pm.loadPlugin('gpuCache') ct = pm.currentTime() cacheDir = bs_pathGenerator.bs_getAssetDir( astType=assetType, astName=assetName, astDept=dept)['dept'] + 'gpu/' fileName = bs_pathGenerator.bs_getMainFileName().split('.')[0][:-3] + 'gpu' # create gpu directory if not exist. if not os.path.isdir(cacheDir): os.makedirs(cacheDir) # export gpu cache. pm.gpuCache(st=ct, et=ct, o=True, ot=40000, wm=True, df='ogawa', dir=cacheDir, fileName=fileName, ado=True) # check gpu maya file is exist or not. if not os.path.isfile(cacheDir + fileName + '.ma'): bs_makeGpuMayaFile() bs_qui.bs_displayMessage( 'success', 'Gpu Cache Exported And Gpu Maya File also Created..') else: bs_qui.bs_displayMessage('success', 'Gpu Cache Exported..')