def export(element, selection=None, startFrame=None, endFrame=None): proj = Project() bodyName = element.get_parent() body = proj.get_body(bodyName) abcFilePath = element.get_cache_dir() #TODO we don't want to put them into the element cache right away. We want to put them in a seperate place and then copy them over later. if startFrame is None: startFrame = pm.playbackOptions(q=True, animationStartTime=True) if endFrame is None: endFrame = pm.playbackOptions(q=True, animationEndTime=True) if body.is_shot(): startFrame -= 5 endFrame += 5 files = exportReferences(abcFilePath, tag='BYU_Alembic_Export_Flag', selectionMode=True, startFrame=startFrame, endFrame=endFrame) result = message_gui.yes_or_no( 'Are there any crowds that need to be exported?') if result: exportCrowd(abcFilePath, 'BYU_Crowd_Agent_Flag', tag='BYU_Alembic_Export_Flag', startFrame=startFrame, endFrame=endFrame) elif body.is_asset(): if body.get_type() == AssetType.SET: files = exportReferences(abcFilePath) else: files = exportAll(abcFilePath, element=element) elif body.is_crowd_cycle(): files = exportAll(abcFilePath, tag='BYU_Alembic_Export_Flag', startFrame=startFrame, endFrame=endFrame, element=element) if not files: #Maybe this is a bad distinction but None is if it was canceled or something and empty is if it went but there weren't any alembics if files is None: return message_gui.error('No alembics were exported') return for abcFile in files: os.system('chmod 774 ' + abcFile) #TODO install the geometry print 'These are the files that we are returning', files return files
def go(): result = message_gui.binary_option("We are going to do crowds cycles a little differently now. This way is going to be more direct, less error prone and there is going to be a lot less stuff for maya to load so it should make the process a little faster. We are going to do it just like we would make any other asset with a couple of differences. I think it's going to work out a lot better.", "View Instuctions", "Done") if result: subprocess.call(['xdg-open', 'https://byu-animation.github.io/crowds.html']) return fileName = pm.sceneName() listOfChanges = pm.dgmodified() #Check to see if there are unsaved changes if listOfChanges is not None: result = message_gui.yes_or_no('In order to continue the file will need to be saved and closed. Are you ready to proceed?') if not result: return None name = message_gui.input('What is the name of this cycle?') if name is None: return None invalidInput = True while(invalidInput): firstFrame = message_gui.input('What is the first frame of the cycle?') try: firstFrame = int(firstFrame) except ValueError: message_gui.error('Please enter a number') continue invalidInput = False invalidInput = True while(invalidInput): lastFrame = message_gui.input('What is the last frame of the cycle?') try: lastFrame = int(lastFrame) except ValueError: message_gui.error('Please enter a number') continue invalidInput = False name = name.replace(' ', '_') project = Project() try: cycleAsset = project.create_crowd_cycle(name) except EnvironmentError, e: message_gui.error('There is already an crowd cycle with that name.', details=e) return None
def post_publish(): element = mari_publish_dialog.result if mari_publish_dialog.published: #save the file project = mari.projects.current() project_id = project.uuid() export_images.go() project.save() project.close() #Publish user = mari_publish_dialog.user src = mari_publish_dialog.src comment = mari_publish_dialog.comment env = Environment() user_dir = env.get_user_workspace() archive_file = os.path.join(user_dir, str(src) + '.mra') mari.projects.archive(project_id, archive_file) dst = element.publish(user, archive_file, comment) #Ensure file has correct permissions try: os.chmod(dst, 0660) except: pass #Delete Temp file try: os.remove(archive_file) except: print 'There was an error while removing the temp file.' pass remove = message_gui.yes_or_no( 'The Mari Project is safely published. Would you like to remove the project from your Mari cache?' ) if remove: mari.projects.remove(project_id)
def export(self): self.close() # Get user, project, and time info so we can make a temp folder user = self.environment.get_current_username() projectName = self.project.get_name().lower() time_now = datetime.datetime.now() #Make a temp folder for the rib files based on the user and the current time ribDir = self.project.get_project_dir( ) + '/ribs/' + user + '_' + time_now.strftime('%m%d%y_%H%M%S') print 'ribDir', ribDir, ' renderNodes size: ', len(self.renderNodes) os.makedirs(ribDir) # Sanitize job title title = re.sub(r'[{}"\']', '', str(self.jobName.text())).strip(' \t\n\r') if len(title) == 0: title = self.empty_text numCores = int( re.sub(r'[{}"\']', '', str(self.numCores.text())).strip(' \t\n\r')) if numCores < 1: numCores = 1 # This job we send to tractor job = author.Job() job.title = title job.priority = self.priority.currentIndex() path = '/opt/pixar/RenderManProServer-21.5/bin/' job.envkey = [ 'setenv PATH=' + path + ' RMANTREE=/opt/pixar/RenderManProServer-21.5' ] job.service = 'PixarRender' job.comment = 'Spooled by ' + user # Loop through each frame of our nodes and create frame tasks and append it to the job script for index, node in enumerate(self.renderNodes): # Make sure this node was selected for export print node.name() if self.select.item(index).isSelected(): name = node.name() validFrameRange = node.parm('trange').eval() if validFrameRange == 0: start = int(hou.frame()) end = int(hou.frame()) step = 1 else: start = int(node.parm('f1').eval()) end = int(node.parm('f2').eval()) step = int(node.parm('f3').eval()) task = author.Task() task.title = '%s [%d-%d]' % (name, start, end) oldOutputMode = node.parm('rib_outputmode').eval() try: oldDiskFile = node.parm('soho_diskfile').expression() useExpression = True print 'We are getting rid of expressiion' except: oldDiskFile = node.parm('soho_diskfile').eval() useExpression = False print 'we didn\'t get rid of them' # Activate rib output node.parm('rib_outputmode').set(True) node.parm('soho_diskfile').deleteAllKeyframes() node.parm('soho_diskfile').set(ribDir + ('/%s_$F04.rib' % name)) print 'start rib making' script = os.path.join(self.project.get_project_dir(), 'byu-pipeline-tools', 'houdini-tools', 'parallelRibs', 'taskDistribution.sh') subprocess.call([ 'sh', script, str(start), str(end), str(node.path()), str(saveHipRenderCopy()), str(numCores) ]) print 'finish rib making' # Loop through every frame in framerange for frame in range(start, end + 1, step): subtask = author.Task() subtask.title = 'Frame %04d' % (frame) ribFile = '%s/%s_%04d.rib' % (ribDir, name, frame) print 'Here is the rib file ', ribFile # Commands for Debugging cmdPATH = author.Command() cmdPATH.argv = ['echo', '${PATH}'] cmdRMANTREE = author.Command() cmdRMANTREE.argv = ['echo', '${RMANTREE}'] printenv = author.Command() printenv.argv = ['printenv'] # subtask.addCommand(cmdPATH) # subtask.addCommand(cmdRMANTREE) # subtask.addCommand(printenv) # Real Commands command = author.Command() command.argv = ['prman', '-progress', ribFile] command.service = 'PixarRender' subtask.addCommand(command) task.addChild(subtask) job.addChild(task) # Restore rib output node.parm('soho_outputmode').set(oldOutputMode) if useExpression: node.parm('soho_diskfile').setExpression(oldDiskFile) else: node.parm('soho_diskfile').set(oldDiskFile) command = author.Command() command.argv = ['rm', '-rf', ribDir] job.addCleanup(command) # print 'This is the new job script \n', job.asTcl() # Attempt to spool job, with the option to keep trying choice = True while choice: try: job.spool() message_gui.info('Job sent to Tractor!') break except Exception as err: choice = message_gui.yes_or_no( 'We ran into this problem while spooling the job:\nWould you like to try again?', details=str(err), title='Continue?') #Cleanup ifd files, if they didn't want to retry if not choice: shutil.rmtree(ribDir)