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_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_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 exportGPU(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 bs_setManager.bs_makeGpuCacheFile() self.addGpuPath()
def addItemInTable(self): self.bsap_prevVers_tableWidget.setRowCount(0) dept, assetType, assetName, uid, episode = bs_pathGenerator.bs_getAssetDetails( ) if dept == 'Not Exist' or assetType == 'Not Exist' or assetName == 'Not Exist': bs_qui.bs_displayMessage('warning', 'No Assets Found in Scene.....') return False if self.projectType == 'series': mainFi, verFi = bs_pathGenerator.bs_getAssetFileAndVersions( assetType, dept, assetName, episode=episode) else: mainFi, verFi = bs_pathGenerator.bs_getAssetFileAndVersions( assetType, dept, assetName) # add version details in table widget. for each in mainFi: rowPosition = self.bsap_prevVers_tableWidget.rowCount() self.bsap_prevVers_tableWidget.insertRow(rowPosition) fileName = each.split('/')[-1] fileTime = bs_os.bs_getFileDateTime(each) fileOwner = bs_os.bs_getFileOwner(each) fileSize = bs_os.bs_getFileSize(each) fileComment = 'NUll' self.bsap_prevVers_tableWidget.setItem( rowPosition, 0, QtGui.QTableWidgetItem(fileName)) self.bsap_prevVers_tableWidget.setItem( rowPosition, 1, QtGui.QTableWidgetItem(fileTime)) self.bsap_prevVers_tableWidget.setItem( rowPosition, 2, QtGui.QTableWidgetItem(fileOwner)) self.bsap_prevVers_tableWidget.setItem( rowPosition, 3, QtGui.QTableWidgetItem(fileSize)) self.bsap_prevVers_tableWidget.setItem( rowPosition, 4, QtGui.QTableWidgetItem(fileComment)) for each in verFi: rowPosition = self.bsap_prevVers_tableWidget.rowCount() self.bsap_prevVers_tableWidget.insertRow(rowPosition) fileName = each.split('/')[-1] fileTime = bs_os.bs_getFileDateTime(each) fileOwner = bs_os.bs_getFileOwner(each) fileSize = bs_os.bs_getFileSize(each) fileComment = 'NUll' self.bsap_prevVers_tableWidget.setItem( rowPosition, 0, QtGui.QTableWidgetItem(fileName)) self.bsap_prevVers_tableWidget.setItem( rowPosition, 1, QtGui.QTableWidgetItem(fileTime)) self.bsap_prevVers_tableWidget.setItem( rowPosition, 2, QtGui.QTableWidgetItem(fileOwner)) self.bsap_prevVers_tableWidget.setItem( rowPosition, 3, QtGui.QTableWidgetItem(fileSize)) self.bsap_prevVers_tableWidget.setItem( rowPosition, 4, QtGui.QTableWidgetItem(fileComment)) self.bsap_prevVers_tableWidget.resizeColumnsToContents()
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 __init__(self, parent=None): super(Bs_TextureManager, self).__init__(parent) self.setupUi(self) # set logo image. imageRootPath = os.path.dirname(os.path.dirname(__file__)) imageMap = imageRootPath + '/bs_images/bsw_textureManger.png' self.bstm_logo_lbl.setPixmap(imageMap) # change current font. headerFont = QtGui.QFont("Times", 12, QtGui.QFont.Bold) objFont = QtGui.QFont("Verdana", 10, QtGui.QFont.StyleItalic) self.label_2.setFont(headerFont) self.label_4.setFont(headerFont) self.bstm_assetName_lbl.setFont(objFont) self.bstm_assetType_lbl.setFont(objFont) # fill asset details. assetCategory, assetType, assetName, uid = bs_pathGenerator.bs_getAssetDetails( ) self.bstm_assetName_lbl.setText(assetName) self.bstm_assetType_lbl.setText(assetType) # set button clicked commands. self.bstm_exportShader_pb.clicked.connect(self.exportShaders) self.bstm_importShader_pb.clicked.connect(self.importShaders) # exported shader path line edit fill and set read only. self.addShaderPathInLineEdit() self.bstm_exportPath_le.setReadOnly(True) self.bstm_exportedPath_pb.clicked.connect( self.openExportedShaderPathDir) # get and set all file texture root path. if bs_fileTexture.bs_getAllFileTexturePathIfValid(): if bs_fileTexture.bs_checkAllFileTexturePathIsComingFromEnv(): self.bstm_currentRootPath_le.setText( bs_fileTexture.bs_checkAllFileTexturePathIsComingFromEnv()) self.bstm_convertPath_le.setText( bs_fileTexture.bs_checkAllFileTexturePathIsComingFromEnv()) else: self.bstm_currentRootPath_le.setText( 'all path are not coming with environment variable.') else: self.bstm_currentRootPath_le.setText( 'file texture path not from valid directory...') self.bstm_currentRootPath_pb.clicked.connect(self.openSourceImageDir) self.bstm_convertPath_pb.clicked.connect(self.convertPath) self.bstm_refresh_pb.clicked.connect(self.refresh) self.bstm_currentRootPath_le.setReadOnly(True) self.bstm_convertPath_le.setReadOnly(True)
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 __init__(self, parent=None): super(Bs_SetManager, self).__init__(parent) self.setupUi(self) # fill asset entries and set fonts. assetCategory, assetType, assetName, uid = bs_pathGenerator.bs_getAssetDetails( ) self.bssm_category_lbl.setText(assetCategory) self.bssm_assetType_lbl.setText(assetType) self.bssm_assetName_lbl.setText(assetName) # change current font. headerFont = QtGui.QFont("Times", 12, QtGui.QFont.Bold) objFont = QtGui.QFont("Verdana", 10, QtGui.QFont.StyleItalic) self.label_2.setFont(headerFont) self.label_4.setFont(headerFont) self.label_5.setFont(headerFont) self.bssm_category_lbl.setFont(objFont) self.bssm_assetName_lbl.setFont(objFont) self.bssm_assetType_lbl.setFont(objFont) # ui changes. self.actionExit.triggered.connect(self.close) self.bssm_setElementLib_LW.setSelectionMode( QtGui.QAbstractItemView.ExtendedSelection) self.bssm_selectedItems_LW.setSelectionMode( QtGui.QAbstractItemView.ExtendedSelection) self.bssm_currentSetElem_LW.setSelectionMode( QtGui.QAbstractItemView.ExtendedSelection) self.addGpuPath() # ui connections self.addAllSetElements() self.addReferencedElem() self.bssm_addElem_PB.clicked.connect(self.addItemsInSelectedLW) self.bssm_remElem_PB.clicked.connect( lambda: bs_qui.bs_removeSelectedItemsFromQLW( self.bssm_selectedItems_LW)) self.bssm_addElemInScene_PB.clicked.connect(self.referenceElements) self.bssm_removeRef_PB.clicked.connect(self.removeSelectedReferences) self.bssm_refresh_PB.clicked.connect(self.refresh) self.bssm_exportGPU_PB.clicked.connect(self.exportGPU) self.bssm_GPUfilePath_PB.clicked.connect(self.openGpuDirectory) self.bssm_GPUcachePath_PB.clicked.connect(self.openGpuDirectory)
def referenceElements(self): # get environments. serverPath = bs_pathGenerator.bs_getEnvDetails()['rootPath'] # 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 elements = list() for x in range(self.bssm_selectedItems_LW.count()): elements.append(self.bssm_selectedItems_LW.item(x).text()) # reference and parent all selected setElements. for each in elements: mainFile, verFiles = bs_pathGenerator.bs_getAssetFileAndVersions( 'SetElement', 'Rig', each) if len(mainFile.keys()) == 1: filePath = mainFile[mainFile.keys()[0]]['path'] filePath = filePath.replace(serverPath, '$BSW_PROD_SERVER/') ns = bs_reference.bs_createReference(filePath, prefixStyle='fileName') pm.parent(ns.namespace + ':rig_grp', 'setElements_grp') self.refresh()
def connections(self): imageMap = imageRootPath + '/bs_images/bsw_assetPublishLogo.png' self.bsap_publishLogo_lbl.setPixmap(imageMap) assetCategory, assetType, assetName, uid, episode = bs_pathGenerator.bs_getAssetDetails( ) self.bsap_category_lbl.setText(assetCategory) self.bsap_assetType_lbl.setText(assetType) self.bsap_assetName_lbl.setText(assetName) if self.projectType == 'series': self.bsap_episode_lbl.setText(episode) # change current font. headerFont = QtGui.QFont("Times", 12, QtGui.QFont.Bold) objFont = QtGui.QFont("Verdana", 10, QtGui.QFont.StyleItalic) self.label.setFont(headerFont) self.label_4.setFont(headerFont) self.label_5.setFont(headerFont) self.bsap_category_lbl.setFont(objFont) self.bsap_assetType_lbl.setFont(objFont) self.bsap_assetName_lbl.setFont(objFont) if self.projectType == 'series': self.bsap_episodeTag_lbl.setFont(headerFont) self.bsap_episode_lbl.setFont(objFont)
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..')
def bs_publishCurrentAsset(comment=None): """ @ publish current opened asset. Args: comment (str): comment on publish. Returns: mainFilePath And versionFilePath. """ # get environments. projectType = bs_pathGenerator.bs_getEnv()['projectType'] assetDept, assetType, assetName, uid, episode = bs_pathGenerator.bs_getAssetDetails( ) if assetDept == 'Not Exist' or assetType == 'Not Exist' or assetName == 'Not Exist' or uid == 'Not Exist': bs_qui.bs_displayMessage('error', 'Asset not found To Publish.....') return False # get asset directories and create directories if not exist. if projectType == 'series': mainDir = bs_pathGenerator.bs_getAssetDeptDirs( assetType, assetName, episode=episode)[assetDept] verDir = bs_pathGenerator.bs_getAssetDeptDirs( assetType, assetName, episode=episode)[assetDept + 'Version'] bs_pathGenerator.bs_createAssetDirectories(assetType, assetName, episode=episode) else: mainDir = bs_pathGenerator.bs_getAssetDeptDirs(assetType, assetName)[assetDept] verDir = bs_pathGenerator.bs_getAssetDeptDirs( assetType, assetName)[assetDept + 'Version'] bs_pathGenerator.bs_createAssetDirectories(assetType, assetName) # get file paths to save the file. mainFilePath = mainDir + bs_pathGenerator.bs_getCurrentAssetMainFileName() versionFileName = bs_pathGenerator.bs_versionUpPath(verDir) # create new version file name if no version exist. if not versionFileName: versionFileName = bs_pathGenerator.bs_getCurrentAssetMainFileName( )[:-3] + '_v001.ma' versionFilePath = verDir + versionFileName # save version File. pm.saveAs(versionFilePath) # copy main version file and save as main File if fail then save manually. try: shutil.copy2(versionFilePath, mainFilePath) except: pm.saveAs(mainFilePath) # get version screenshot. imageFilePath = verDir + 'screenshot/' + versionFileName[:-3] + '.jpg' bs_screenshot.bs_getScreenShot(imageFilePath) # copy screenshot for main file. try: shutil.copy2(imageFilePath, imageFilePath[:-9] + '.jpg') except: pass # add entry in database. try: tableName = str(mainFilePath.split('/')[-1][:-3]) # mainFile entries. mainFileName = str(mainFilePath.split('/')[-1]) mainFileOwner = bs_os.bs_getFileOwner(mainFilePath) mainFileSize = bs_os.bs_getFileSize(mainFilePath) mainFileTime = bs_os.bs_getFileDateTime(mainFilePath) addInfoDB = bs_database.Bs_Database() addInfoDB.bs_databaseAssetPublish(tableName, mainFileName, mainFileOwner, mainFileSize, mainFileTime, comment) # version File entries. verFileName = str(versionFilePath.split('/')[-1]) verFileOwner = bs_os.bs_getFileOwner(mainFilePath) verFileSize = bs_os.bs_getFileSize(mainFilePath) verFileTime = bs_os.bs_getFileDateTime(mainFilePath) addInfoDB = bs_database.Bs_Database() addInfoDB.bs_databaseAssetPublish(tableName, verFileName, verFileOwner, verFileSize, verFileTime, comment) # print message. bs_qui.bs_displayMessage('success', 'Asset Publish Successfully...') except: bs_qui.bs_displayMessage( 'success', 'Asset Publish Successfully... But database is not not connected') return mainFilePath, versionFilePath