def createFlipbook(): ''' Create hardware viewport render :return: ''' # Build 001 version of flipbook file path flipbookPath = dna.buildFilePath('001', dna.fileTypes['flipbookSequence'], scenePath=hou.hipFile.path()) # Check FB file path of 001 version # If flipbook not exists, use 001 version. If exist, ask user which version to use. dna.versionSolverState = None state = dna.versionSolver(flipbookPath, dna.fileTypes['flipbookSequence']) if state == 'SNV': # If exists and user choose save next version flipbookPath = dna.buildPathNextVersionFolder(dna.buildPathLatestVersionFolder(flipbookPath)) dna.createFolder(flipbookPath) elif state == 'OVR': # If exists and user choose overwrite latest existing version flipbookPath = dna.buildPathLatestVersionFolder(flipbookPath) else: if state: # File does not exists, save it as is. flipbookPath = state # Create FOLDER for HIP dna.createFolder(flipbookPath) else: # User cancel action print '>> Canceled!' return # Run FB and save to a chosen file path runFB(flipbookPath)
def render(self, shotItems): ''' Render list of shots :param shotItems: list of shot dictionaries to render :return: ''' print '>> Rendering list of shots...' if self.needRender(shotItems): for n, shotItem in enumerate(shotItems): renderScenePath = dna.buildFilePath(shotItem['hip'], dna.fileTypes['renderScene'], sequenceNumber=shotItem['E'], shotNumber=shotItem['S']) print '>> Rendering shot [ {0} - {1} ]...'.format(shotItem['E'], shotItem['S']) try: hou.hipFile.load(renderScenePath, suppress_save_prompt=True) rop = hou.node('/out/{}'.format(dna.mantra)) rop.render(frame_range=(int(shotItem['start']), int(shotItem['end']))) print '>> Shot complete' except: print '>> Rendering of shot FAILS! Reload render...' self.addShots() # Reload shots shotItems = self.readShotTable() # read table self.render([shotItems[n]]) print '>> Rendering list of shots done!' self.addShots() # Reload shots
def SNV(self, filePath): # Save NEXT version of flipbook fileLocation = dna.analyzeFliePath(filePath)['fileLocation'] fileName = dna.analyzeFliePath(filePath)['fileName'] latestVersion = dna.extractLatestVersionFolder(fileLocation) # '002' nextVersion = '{:03d}'.format(int(latestVersion) + 1) filePath = dna.buildFilePath(nextVersion, dna.fileTypes['flipbookSequence'], scenePath=hou.hipFile.path()) os.makedirs(dna.analyzeFliePath(filePath)['fileLocation']) runFB(filePath)
def openShotHip(self, fileTypes): sequenceNumber = self.ui_shot.com_shotSequence.currentText() shotNumber = self.ui_shot.lin_shotName.text() # Build path to a 001 version of HIP file pathScene = dna.buildFilePath('001', fileTypes, sequenceNumber=sequenceNumber, shotNumber=shotNumber) # Get latest file version pathScene = dna.buildPathLatestVersionFile(pathScene) # Open file hou.hipFile.load(pathScene)
def createFlipbook(): # Setup flipbook settings settings.resolution(dna.resolution_LR) settings.frameRange((dna.frameStart, hou.playbar.frameRange()[1])) # Build 001 version of flipbook file path flipbookPath = dna.buildFilePath('001', dna.fileTypes['flipbookSequence'], scenePath=hou.hipFile.path()) fileLocation = dna.analyzeFliePath(flipbookPath)['fileLocation'] if not os.path.exists(fileLocation): # Write flipbook if not exists os.makedirs(fileLocation) runFB(flipbookPath) else: # If 001 file exists get latest version latestVersion = dna.extractLatestVersionFolder(fileLocation) # Build latest existing path flipbookPath = dna.buildFilePath(latestVersion, dna.fileTypes['flipbookSequence'], scenePath=hou.hipFile.path()) # Ask user to save next version or overwrite latest win = SNV(flipbookPath) win.show()
def openHip(self): splitter = self.sender().parent() index = self.ui.tab_shots.indexAt(splitter.pos()) sequenceNumber = self.ui.tab_shots.item(index.row(), 0).text() shotNumber = self.ui.tab_shots.item(index.row(), 1).text() hipVersion = self.ui.tab_shots.item(index.row(), 2).text() renderScenePath = dna.buildFilePath(hipVersion, dna.fileTypes['renderScene'], sequenceNumber=sequenceNumber, shotNumber=shotNumber) hou.hipFile.load(renderScenePath)
def openFolder(self): splitter = self.sender().parent() index = self.ui.tab_shots.indexAt(splitter.pos()) sequenceNumber = self.ui.tab_shots.item(index.row(), 0).text() shotNumber = self.ui.tab_shots.item(index.row(), 1).text() exrVersion = self.ui.tab_shots.item(index.row(), 3).text() renderFilePath = dna.buildFilePath(exrVersion, dna.fileTypes['renderSequence'], sequenceNumber=sequenceNumber, shotNumber=shotNumber) renderFileFloder = dna.analyzeFliePath(renderFilePath)['fileLocation'] subprocess.Popen('explorer "{}"'.format(renderFileFloder.replace('/', '\\')))
def openAssetHip(self): ''' Open latest version of asset hip file :return: ''' assets = self.ui.lis_assets.selectedItems() assetName = assets[0].text() # Get asset data assetData = dna.getAssetDataByName(genesAssets, assetName) # Build path to a 001 version of HIP file fileType = dna.fileTypes[assetData['sg_asset_type']] pathScene = dna.buildFilePath('001', fileType, assetName=assetName) # Get latest file version pathScene = dna.buildPathLatestVersionFile(pathScene) # Open file hou.hipFile.load(pathScene)
def populateShotItem(self, shotItem): ''' Build shot items from database and populate UI :param shotItem: render shot data dictionary :return: ''' sequenceNumber, shotNumber = shotItem[shotItemParams[0]], shotItem[ shotItemParams[1]] # Get shot frame range from database shotData = dna.getShotData(sequenceNumber, shotNumber, genesShots) # Get end frame frameEnd = shotData['sg_cut_out'] if frameEnd: frameEnd = int(frameEnd) else: print '>> Error! Set the end frame in shot properties.' return shotItem['range'] = '{0:03d} - {1:03d}'.format(dna.frameStart, frameEnd) # Get latest render hip and latest render folder # Assume that in latest hip the render path set to the latest render folder # (TBD switch to published version) renderScenePath = dna.buildFilePath('001', dna.fileTypes['renderScene'], sequenceNumber=sequenceNumber, shotNumber=shotNumber) latestHIP = dna.buildPathLatestVersionFile(renderScenePath) pathMapHIP = dna.analyzeFliePath(latestHIP) renderSequencePath = dna.buildFilePath('001', dna.fileTypes['renderSequence'], sequenceNumber=sequenceNumber, shotNumber=shotNumber) shotItem['hip'] = pathMapHIP['fileVersion'] pathMapEXR = dna.analyzeFliePath(renderSequencePath) fileLocation = pathMapEXR['fileLocation'] # Check if folder exists, create if not if not os.path.exists(fileLocation): os.makedirs(fileLocation) latestEXR = dna.extractLatestVersionFolder(fileLocation) shotItem['exr'] = latestEXR renderFilePath = dna.buildFilePath(latestEXR, dna.fileTypes['renderSequence'], sequenceNumber=sequenceNumber, shotNumber=shotNumber) pathMapEXR = dna.analyzeFliePath(renderFilePath) latestFolderPath = pathMapEXR['fileLocation'] listExisted = glob.glob('{0}*.exr'.format(latestFolderPath)) # Clean list from partially rendered files 'E010_S060_012.1.exr.mantra_checkpoint' listCorruptedFiles = glob.glob( '{0}*.exr.mantra_checkpoint'.format(latestFolderPath)) listCorrupted = [] for file in listCorruptedFiles: file = file.replace('\\', '/').replace('.mantra_checkpoint', '') listCorrupted.append(file.split('/')[-1]) doneStart, doneEnd = self.extractFrames(listExisted, listCorrupted) if doneStart != 0: shotItem['done'] = '{0:03d} - {1:03d}'.format(doneStart, doneEnd) else: shotItem['done'] = '' # Check if sequence is not rendered completely # Otherwise set START to a blank value. This will be skipped when render if not doneEnd == shotData['sg_cut_out']: shotItem['start'] = str(doneEnd + 1) shotItem['end'] = str(shotData['sg_cut_out']) else: shotItem['start'] = '' shotItem['end'] = '' self.addShotRow(shotItem) return shotItem