def correctExt(self, origin, lfilepath): if str(hou.licenseCategory()) == "licenseCategoryType.Commercial": return os.path.splitext(lfilepath)[0] + ".hip" elif str(hou.licenseCategory()) == "licenseCategoryType.Indie": return os.path.splitext(lfilepath)[0] + ".hiplc" else: return os.path.splitext(lfilepath)[0] + ".hipnc"
def getLicenseType(): if hou.licenseCategory() == hou.licenseCategoryType.Indie: return ".hiplc" elif hou.licenseCategory() == hou.licenseCategoryType.Commercial: return ".hip" else: return ".hipnc"
def getSceneExtension(self, origin): if str(hou.licenseCategory()) == "licenseCategoryType.Commercial": return ".hip" elif str(hou.licenseCategory()) == "licenseCategoryType.Indie": return ".hiplc" else: return ".hipnc"
def getExtension() -> str: if hou.licenseCategory() == hou.licenseCategoryType.Indie: return ".hiplc" if hou.licenseCategory() == hou.licenseCategoryType.Commercial: return ".hip" if hou.licenseCategory() == hou.licenseCategoryType.Apprentice: return ".hipnc" return ".hipnc"
def preExecuteState(self): warnings = [] if self.l_taskName.text() == "": warnings.append(["No taskname is given.", "", 3]) rangeType = self.cb_rangeType.currentText() startFrame, endFrame = self.getFrameRange(rangeType) if startFrame is None: warnings.append(["Framerange is invalid.", "", 3]) if self.core.uiAvailable: sceneViewer = hou.ui.paneTabOfType(hou.paneTabType.SceneViewer) if sceneViewer is None: warnings.append([ "No Scene View exists.", "A Scene View needs to be open in the Houdini user interface in order to create a playblast.", 3, ]) if (hou.licenseCategory() == hou.licenseCategoryType.Apprentice and self.chb_resOverride.isChecked() and (self.sp_resWidth.value() > 1280 or self.sp_resHeight.value() > 720)): warnings.append([ "The apprentice version of Houdini only allows flipbooks up to 720p.", "The resolution will be reduced to fit this restriction.", 2, ]) return [self.state.text(0), warnings]
def fetch_data_from_mantra_node(input_node): """Collects data form Mantra input node. Assumes that input node is Mantra node Args: input_node: hou.Node, Mantra node. Returns: {str, object}, Submission parameters. """ output_picture = input_node.parm('vm_picture').unexpandedString() result = dict(output_filename=os.path.basename(output_picture), renderer='mantra', renderer_version=hou.applicationVersion(), render_current_frame=False) if input_node.parm('trange').evalAsString() == 'off': current_frame = hou.frame() result['frame_begin'] = current_frame result['frame_end'] = current_frame result['step'] = 1 # Resolution limits only apply to non- and limited-commercial, so "Render Current Frame" # isn't needed otherwise. result['render_current_frame'] = ( hou.licenseCategory() != hou.licenseCategoryType.Commercial) else: result['frame_begin'] = input_node.parm('f1').eval() result['frame_end'] = input_node.parm('f2').eval() result['step'] = input_node.parm('f3').eval() return result
def fetch_data_from_mantra_node(input_node): """Collects data form Mantra input node. Assumes that input node is Mantra node Args: input_node: hou.Node, Mantra node. Returns: {str, object}, Submission parameters. """ output_picture = input_node.parm('vm_picture').unexpandedString() result = dict( output_filename=os.path.basename(output_picture), renderer='mantra', renderer_version=hou.applicationVersion(), render_current_frame=False ) if input_node.parm('trange').evalAsString() == 'off': current_frame = hou.frame() result['frame_begin'] = current_frame result['frame_end'] = current_frame result['step'] = 1 # Resolution limits only apply to non- and limited-commercial, so "Render Current Frame" # isn't needed otherwise. result['render_current_frame'] = (hou.licenseCategory() != hou.licenseCategoryType.Commercial) else: result['frame_begin'] = input_node.parm('f1').eval() result['frame_end'] = input_node.parm('f2').eval() result['step'] = input_node.parm('f3').eval() return result
def node_OnCreated(node): # Skip asset internal nodes if (node.isInsideLockedHDA() == True): return if enabled(): node_hda_file_path = node.type().definition().libraryFilePath() LYNX_analytics.event_send( hou.applicationPlatformInfo(), hou.applicationName(), hou.applicationVersionString(), hou.licenseCategory().name(), "Plugin", "SideFX/Houdini/otls/" + os.path.split(node_hda_file_path)[-1], str(node.type().name()), 0)
def check_params(params): """Validate submission parameters Args: params: {str, object}, Parameters to be validated. Raises: ParameterError: One of the parameters is invalid. Returns: {str, object}, Valid paramters """ if not params.get('proj_name', ''): raise ParameterError('Project name cannot be empty') if not params.get('instance_type', ''): raise ParameterError('Machine type cannot be empty') _, scene_ext = os.path.splitext(ZyncHoudiniJob.scene_path()) # Standalone rendering is not available for not-commercial or # limited-commercial users. commercial_license = ( hou.licenseCategory() == hou.licenseCategoryType.Commercial) if not commercial_license: params['use_standalone'] = 0
def save_as(self, version, run_pre_publishers=True): """the save action for houdini environment """ if not version: return from stalker import Version assert isinstance(version, Version) # get the current version, # and store it as the parent of the new version current_version = self.get_current_version() # initialize path variables by using update_paths() version.update_paths() # set the extension to hip version.extension = self.extensions[hou.licenseCategory()] # define that this version is created with Houdini version.created_with = self.name # create the folder if it doesn't exists try: os.makedirs(os.path.dirname(version.absolute_full_path)) except OSError: # dirs exist pass # houdini uses / instead of \ under windows # lets fix it # set the environment variables self.set_environment_variables(version) # set the render file name self.set_render_filename(version) # set the fps from stalker import Shot shot = version.task.parent if version and isinstance(shot, Shot): # set to shot.fps if this is a shot related scene self.set_fps(shot.fps) # also set frame range if this is the first version if version.version_number == 1: self.set_frame_range(shot.cut_in, shot.cut_out) else: # set to project fps self.set_fps(version.task.project.fps) # houdini accepts only strings as file name, no unicode support as I # see hou.hipFile.save(file_name=str(version.absolute_full_path)) # set the environment variables again self.set_environment_variables(version) # append it to the recent file list self.append_to_recent_files(version.absolute_full_path) # update the parent info if current_version: version.parent = current_version # update database with new version info from stalker.db.session import DBSession DBSession.commit() # create a local copy self.create_local_copy(version) return True
def executeState(self, parent, useVersion="next"): if self.l_taskName.text() == "": return [self.state.text(0) + ": error - No taskname is given. Skipped the activation of this state."] sceneViewer = hou.ui.paneTabOfType(hou.paneTabType.SceneViewer) if sceneViewer is None: return [self.state.text(0) + ": error - No Scene View exists. A Scene View needs to be open in the Houdini user interface in order to create a playblast."] if self.curCam is not None: try: self.curCam.name() except: return [self.state.text(0) + ": error - Camera is invalid (%s)." % self.cb_cams.currentText()] psettings = sceneViewer.flipbookSettings() if self.chb_resOverride.isChecked(): if hou.licenseCategory() == hou.licenseCategoryType.Apprentice and self.chb_resOverride.isChecked() and (self.sp_resWidth.value() > 1280 or self.sp_resHeight.value() > 720): aspect = self.sp_resWidth.value()/float(self.sp_resHeight.value()) if aspect> (1280/float(720)): res = [1280, 1280/aspect] else: res = [720*aspect, 720] else: res = [self.sp_resWidth.value(), self.sp_resHeight.value()] panel = sceneViewer.clone().pane().floatingPanel() dspSet = sceneViewer.curViewport().settings().displaySet(hou.displaySetType.SceneObject) shdMode = hou.GeometryViewportDisplaySet.shadedMode(dspSet) sceneViewer = panel.paneTabOfType(hou.paneTabType.SceneViewer) height = int(res[1])+200 ratio = float(res[0])/float(res[1]) if sceneViewer.curViewport().settings().camera() is None: panel.setSize((height, height)) rat1 = sceneViewer.curViewport().settings().viewAspectRatio() panel.setSize((int(height*ratio/rat1), int(height*rat1))) else: panel.setSize((int(res[0])+200, int(res[1])+200)) fdspSet = sceneViewer.curViewport().settings().displaySet(hou.displaySetType.SceneObject) fdspSet.setShadedMode(shdMode) psettings = sceneViewer.flipbookSettings() psettings.useResolution(True) psettings.resolution((int(res[0]), int(res[1]))) else: psettings.useResolution(False) psettings.cropOutMaskOverlay(True) if self.curCam is not None: sceneViewer.curViewport().setCamera(self.curCam) fileName = self.core.getCurrentFileName() outputName, outputPath, hVersion = self.getOutputName(useVersion=useVersion) outLength = len(outputName) if platform.system() == "Windows" and outLength > 255: return [self.state.text(0) + " - error - The outputpath is longer than 255 characters (%s), which is not supported on Windows. Please shorten the outputpath by changing the comment, taskname or projectpath." % outLength] if not os.path.exists(outputPath): os.makedirs(outputPath) self.core.saveVersionInfo(location=os.path.dirname(outputPath), version=hVersion, origin=fileName) psettings.output(outputName) self.l_pathLast.setText(outputName) self.l_pathLast.setToolTip(outputName) self.b_openLast.setEnabled(True) self.b_copyLast.setEnabled(True) self.stateManager.saveStatesToScene() hou.hipFile.save() if self.chb_globalRange.isChecked(): jobFrames = (self.stateManager.sp_rangeStart.value(), self.stateManager.sp_rangeEnd.value()) else: jobFrames = (self.sp_rangeStart.value(), self.sp_rangeEnd.value()) psettings.frameRange(jobFrames) self.core.callHook("PrePlayblast", args={"prismCore":self.core, "scenefile":fileName, "startFrame":jobFrames[0], "endFrame":jobFrames[0], "outputName":outputName}) try: sceneViewer.flipbook() if "panel" in locals(): panel.close() self.core.callHook("PostPlayblast", args={"prismCore":self.core, "scenefile":fileName, "startFrame":jobFrames[0], "endFrame":jobFrames[0], "outputName":outputName}) if len(os.listdir(outputPath)) > 0: return [self.state.text(0) + " - success"] else: return [self.state.text(0) + " - unknown error (files do not exist)"] except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() erStr = ("%s ERROR - houPlayblast %s:\n%s" % (time.strftime("%d/%m/%y %X"), self.stateManager.version, traceback.format_exc())) self.core.writeErrorLog(erStr) return [self.state.text(0) + " - unknown error (view console for more information)"] if "Result=Success" in result: return [self.state.text(0) + " - success"] else: erStr = ("%s ERROR - houPlayblastPublish %s:\n%s" % (time.strftime("%d/%m/%y %X"), self.stateManager.version, result)) self.core.writeErrorLog(erStr) return [self.state.text(0) + " - error - " + result]
def save_scene(kwargs=None, task=None, desc=None): if kwargs: ctrl = kwargs['ctrlclick'] else: ctrl = False # Find scene_data node scene_data = None scene_data_nodes = [] for n in hou.node('/obj').children(): if n.type().nameComponents()[2].startswith('scene_data'): scene_data_nodes.append(n) if len(scene_data_nodes) > 1: util.error('Multiple SCENE DATA nodes found\nAborting Operation') elif len(scene_data_nodes) == 1: scene_data = scene_data_nodes[0] else: util.error( 'SCENE DATA node not found\nPlease create one and select a scene before saving' ) return # Gather variables save_path = hou.getenv('SAVE_PATH') scene = hou.getenv('SCENE') if not save_path or not scene: util.error( 'Local variables not defined\nPlease use SCENE DATA node to set these correctly' ) return # Set task and desc from curr scene or initialize curr_name = hou.hipFile.basename() regex = r'^(?P<scene>\w+)-(?P<task>\w+)-(?P<full_ver>v(?P<ver>\d{3,}))(-(?P<desc>\w+))?-(?P<user>\w+)' \ r'(\.(?P<ext>\w+))$' match = re.match(regex, curr_name, flags=re.IGNORECASE) if match: if not task: task = match.group('task') if not desc: desc = match.group('desc') if not task: task = '' if not desc: desc = '' ask_input = True if ctrl and task != '': ask_input = False # Input Task and Description if ask_input: repeat = True while repeat: repeat = False user_input = hou.ui.readMultiInput( 'Select Task and Description', ('Task', 'Description (optional'), buttons=('OK', 'Cancel'), initial_contents=(task, desc)) if user_input[0] == 1: return task = user_input[1][0] desc = user_input[1][1] if task == '': util.error('Task cannot be left blank', hou.severityType.Warning) repeat = True continue # Set version regex = '(?P<scene>{scene})-(?P<task>{task})-v(?P<ver_num>\\d{{3,}})'.format( scene=scene, task=task) ver_nums = [] for f in os.listdir(save_path): if not os.path.isdir(f): match = re.match(regex, f, flags=re.IGNORECASE) if match: ver_nums.append(int(match.group('ver_num'))) if len(ver_nums) > 0: high_ver = sorted(ver_nums)[-1] ver = 'v{0:>03}'.format(high_ver + 1) else: ver = 'v001' # Set User user = hou.getenv('USER').lower() components = [scene, task, ver, desc, user] for i, c in enumerate(components): if c and c != '': components[i] = clean_name(c) else: del components[i] # Set extension lic_dict = { 'Commercial': 'hip', 'Indie': 'hiplc', 'Apprentice': 'hipnc', 'ApprenticeHD': 'hipnc', 'Education': 'hipnc' } lic = hou.licenseCategory().name() ext = lic_dict[lic] # Build Filename name = '-'.join(components) filename = '{path}/{name}.{ext}'.format(path=save_path, name=name, ext=ext) # Save hou.hipFile.save(filename)
def executeState(self, parent, useVersion="next"): if not self.core.uiAvailable: return [ self.state.text(0) + ": error - Playblasts are not supported without UI. Use the OpenGL ROP with an ImageRender state instead." ] if self.l_taskName.text() == "": return [ self.state.text(0) + ": error - No taskname is given. Skipped the activation of this state." ] sceneViewer = hou.ui.paneTabOfType(hou.paneTabType.SceneViewer) if sceneViewer is None: return [ self.state.text(0) + ": error - No Scene View exists. A Scene View needs to be open in the Houdini user interface in order to create a playblast." ] if self.curCam is not None: try: self.curCam.name() except: return [ self.state.text(0) + ": error - Camera is invalid (%s)." % self.cb_cams.currentText() ] rangeType = self.cb_rangeType.currentText() startFrame, endFrame = self.getFrameRange(rangeType) if rangeType == "Single Frame": endFrame = startFrame if startFrame is None or endFrame is None: return [self.state.text(0) + ": error - Framerange is invalid"] fileName = self.core.getCurrentFileName() outputName, outputPath, hVersion = self.getOutputName( useVersion=useVersion) outLength = len(outputName) if platform.system() == "Windows" and outLength > 255: return [ self.state.text(0) + " - error - The outputpath is longer than 255 characters (%s), which is not supported on Windows. Please shorten the outputpath by changing the comment, taskname or projectpath." % outLength ] if not os.path.exists(outputPath): os.makedirs(outputPath) self.core.saveVersionInfo(location=outputPath, version=hVersion, origin=fileName) self.l_pathLast.setText(outputName) self.l_pathLast.setToolTip(outputName) self.b_openLast.setEnabled(True) self.b_copyLast.setEnabled(True) self.stateManager.saveStatesToScene() hou.hipFile.save() kwargs = { "state": self, "scenefile": fileName, "startframe": startFrame, "endframe": endFrame, "outputpath": outputName, } self.core.callback("prePlayblast", **kwargs) psettings = sceneViewer.flipbookSettings() if self.chb_resOverride.isChecked(): if (hou.licenseCategory() == hou.licenseCategoryType.Apprentice and self.chb_resOverride.isChecked() and (self.sp_resWidth.value() > 1280 or self.sp_resHeight.value() > 720)): aspect = self.sp_resWidth.value() / float( self.sp_resHeight.value()) if aspect > (1280 / float(720)): res = [1280, 1280 / aspect] else: res = [720 * aspect, 720] else: res = [self.sp_resWidth.value(), self.sp_resHeight.value()] panel = sceneViewer.clone().pane().floatingPanel() dspSet = (sceneViewer.curViewport().settings().displaySet( hou.displaySetType.SceneObject)) shdMode = hou.GeometryViewportDisplaySet.shadedMode(dspSet) sceneViewer = panel.paneTabOfType(hou.paneTabType.SceneViewer) height = int(res[1]) + 200 ratio = float(res[0]) / float(res[1]) if sceneViewer.curViewport().settings().camera() is None: panel.setSize((height, height)) rat1 = sceneViewer.curViewport().settings().viewAspectRatio() panel.setSize((int(height * ratio / rat1), int(height * rat1))) else: panel.setSize((int(res[0]) + 200, int(res[1]) + 200)) fdspSet = (sceneViewer.curViewport().settings().displaySet( hou.displaySetType.SceneObject)) fdspSet.setShadedMode(shdMode) psettings = sceneViewer.flipbookSettings() psettings.useResolution(True) psettings.resolution((int(res[0]), int(res[1]))) else: psettings.useResolution(False) psettings.cropOutMaskOverlay(True) if self.curCam is not None: sceneViewer.curViewport().setCamera(self.curCam) psettings.output(outputName) jobFrames = (startFrame, endFrame) psettings.frameRange(jobFrames) try: sceneViewer.flipbook() if "panel" in locals(): panel.close() if self.cb_formats.currentText() == "mp4": mediaBaseName = os.path.splitext(outputName)[0][:-3] videoOutput = mediaBaseName + "mp4" inputpath = (os.path.splitext(outputName)[0][:-3] + "%04d".replace("4", str(self.core.framePadding)) + os.path.splitext(outputName)[1]) result = self.core.media.convertMedia(inputpath, jobFrames[0], videoOutput) if not os.path.exists(videoOutput): return [ self.state.text(0) + (" - error occurred during conversion of jpg files to mp4\n\n%s" % str(result)) ] delFiles = [] for i in os.listdir(os.path.dirname(outputName)): if i.startswith(os.path.basename( mediaBaseName)) and i.endswith(".jpg"): delFiles.append( os.path.join(os.path.dirname(outputName), i)) for i in delFiles: try: os.remove(i) except: pass kwargs = { "state": self, "scenefile": fileName, "startframe": startFrame, "endframe": endFrame, "outputpath": outputName, } self.core.callback("postPlayblast", **kwargs) if len(os.listdir(outputPath)) > 0: return [self.state.text(0) + " - success"] else: return [ self.state.text(0) + " - unknown error (files do not exist)" ] except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() erStr = "%s ERROR - houPlayblast %s:\n%s" % ( time.strftime("%d/%m/%y %X"), self.core.version, traceback.format_exc(), ) self.core.writeErrorLog(erStr) return [ self.state.text(0) + " - unknown error (view console for more information)" ]
def node_OnCreated(node): # Skip asset internal nodes if (node.isInsideLockedHDA()==True): return if LYNX_analytics.enabled(lambda : int(1-hou.ui.displayMessage(title="LYNX | Analytics",text="We use Google Analytics to collect data about our tools. \n You can find out more about what data is collected on the LYNX GitHub Page. \n Do you want to enable data collection?", buttons=("Yes", "No")))): node_hda_file_path = node.type().definition().libraryFilePath() LYNX_analytics.event_send(hou.applicationPlatformInfo(),hou.applicationName(),hou.applicationVersionString(),hou.licenseCategory().name(),"Plugin", "SideFX/Houdini/otls/"+os.path.split(node_hda_file_path)[-1], str(node.type().name()), 0)