Python hou.expandString() Examples
The following are 9
code examples of hou.expandString().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
hou
, or try the search function
.
Example #1
Source File: launchMplayFromNode.py From Nagamochi with GNU General Public License v3.0 | 5 votes |
def run_mplay(n,nparm): mplay = hou.expandString("$HFS") + "/bin/mplay" path = n.parm(nparm).evalAsString() fps = '-r {}'.format(hou.fps()) #options = None if n.parm('trange').eval()!=0: pathSplit = path.split(".") pathSplit[-2] = "$F" path = ".".join(pathSplit) #options = ' -f {} {} {}'.format(n.parm('f1').eval(),n.parm('f2').eval(),n.parm('f3').eval()) args = [mplay, fps, path] #print args subprocess.Popen(args)
Example #2
Source File: gui.py From batch_textures_convert with MIT License | 5 votes |
def applyFolderPathHou(self, path): """ updates folder_path label when called from houdini button """ if in_hou: path = hou.expandString(path) if path != "": self.folder_path.setText(path.replace(" ; ", self.paths_separator)) self.folder_button.setFileChooserStartDirectory(path.split(self.paths_separator)[0])
Example #3
Source File: asset_checker_core.py From DMNK-Tools with MIT License | 5 votes |
def copy_files_button(self): global _amount_files_copied _amount_files_copied = 0 if QtGui.QGuiApplication.keyboardModifiers() == QtCore.Qt.ShiftModifier: sel_Items = _asset_List.selectedItems() sel_row_list = [] for item in sel_Items: sel_row_list.append(item.row()) for index in range(_asset_List.rowCount()): if index in sel_row_list: self.copy_files(index, "") else: for index in range(_asset_List.rowCount()): self.copy_files(index, "") status_text = "Status: Found - " + \ str(len(_all_Files_List)) + \ " | " + \ "Missing - " + \ str(_amount_Missing_Textures) + \ " | " + \ str(_amount_files_copied) + \ " Files copied to: " + \ self.convert_backslash(hou.expandString(_variable_Name.text())) _status.setText(status_text)
Example #4
Source File: asset_checker.py From DMNK-Tools with MIT License | 5 votes |
def copy_files_button(self): global _amount_files_copied _amount_files_copied = 0 if QtGui.QGuiApplication.keyboardModifiers() == QtCore.Qt.ShiftModifier: sel_Items = _asset_List.selectedItems() sel_row_list = [] for item in sel_Items: sel_row_list.append(item.row()) for index in range(_asset_List.rowCount()): if index in sel_row_list: self.copy_files(index, "") else: for index in range(_asset_List.rowCount()): self.copy_files(index, "") status_text = "Status: Found - " + \ str(len(_all_Files_List)) + \ " | " + \ "Missing - " + \ str(_amount_Missing_Textures) + \ " | " + \ str(_amount_files_copied) + \ " Files copied to: " + \ self.convert_backslash(hou.expandString(_variable_Name.text())) _status.setText(status_text)
Example #5
Source File: rs_tex_manager_core.py From DMNK-Tools with MIT License | 5 votes |
def parse_scene(self): """ Goes through all file references and if a texture is found and it exists it is added to 'tex_list' Items in 'tex_list' are added to the 'QTreeWidget' and to the 'images_dict' """ tex_list = [] tex_parm_names = ["file", "fileName", "tex0", "env_map"] file_refs = hou.fileReferences() for parm, string in file_refs: if parm != None: if parm.name() in tex_parm_names: tex = hou.expandString(string) tex = self.convert_backslash(tex) if tex.endswith(extensions): if os.path.isfile(tex): if tex not in images_dict.keys(): if tex not in tex_list: tex_list.append(tex) for tex in tex_list: # Add textures to QTreeWidget item = QTreeWidgetItem(treeview) item.setText(0, tex) self.append_tex_to_dict(tex_list) # Add textures to 'images_dict' self.resetProgress() # Reset progress bar to 0% self.check_status(tex_list)
Example #6
Source File: tools.py From hou_farm with GNU General Public License v3.0 | 5 votes |
def expand_string_for_rop(rop_node, string_value): """ Expands a string that contains tokens such as $OS which depend on being evaluated with respect to a specific node Args: rop_node (hou.Node): A Houdini node to evaluate this string with respect to string_value (str): The string to expand Returns: String: The expanded string """ cur_pwd_node = hou.pwd() hou.cd(rop_node.path()) result = hou.expandString(string_value) hou.cd(cur_pwd_node.path()) return result
Example #7
Source File: gallery_import.py From Nagamochi with GNU General Public License v3.0 | 4 votes |
def run(N,doptype='pyro_smoke',pane=None): hasTarget = False creatednodes_sop =[] creatednodes_dop =[] parent = None print pane if N: hasTarget = True parent = N.parent() elif pane is not None: parent = pane.pwd() if parent is None: print 'Select any node' return None gal_dir = { 'pyro_smoke':['Nagamochi','SIM__pyro_smoke'], 'pyro_fire':['Nagamochi_Limited','SIM__pyro_fire'], 'pyro_explosion':['Nagamochi_Limited','SIM__pyro_fire'], 'rbdbullet':['Nagamochi','SIM__rbdbullet'], 'rbdbullet_emit':['Nagamochi','SIM__rbdbullet_emit'], } g_infos = gal_dir[doptype] g_cat = g_infos[0] g_name = g_infos[1] gs = hou.galleries.galleries() gnode = None for g in gs: ge = g.galleryEntries(category=g_cat,name_pattern=g_name) if len(ge)>0: gnode = ge[0] break if gnode is not None: cnode = gnode.createChildNode(parent) cnode.setComment('') if cnode.type().name()=='dopnet': cnode.parm('startframe').set(hou.expandString("$FSTART")) if N: cnode.setInput(0,N) cnode.moveToGoodPosition() elif N is None and pane: cnode.setPosition(pane.cursorPosition()) else: print 'failed'
Example #8
Source File: speedtree_importer_core.py From DMNK-Tools with MIT License | 4 votes |
def createGeo(self): global geo_node global matnet # Get Geometry get_Mesh_File = hou.ui.selectFile( title="Select Mesh File", file_type=hou.fileType.Geometry, pattern=("*.bgeo, *.abc, *.obj, *.fbx")) get_Mesh_File_Ext = get_Mesh_File[-3:] get_Mesh_File_Abs = hou.expandString(get_Mesh_File) # Create 'geo' and 'matnet' node geo_node = hou.node("/obj").createNode("geo") matnet = geo_node.createNode("matnet", "Materials") # Get primitive groups depending on mesh file type if get_Mesh_File_Ext == "abc": abc_Node = geo_node.createNode("alembic") abc_Node.parm("fileName").set(get_Mesh_File) abc_Node.parm("loadmode").set(1) abc_Node.parm("polysoup").set(0) # unpack_Node = abc_Node.createOutputNode("unpack") mat_assign_node = abc_Node.createOutputNode("material") prim_groups = self.get_prim_grps(abc_Node) elif get_Mesh_File_Ext == "obj" or get_Mesh_File_Ext == "fbx": file_Node = geo_node.createNode("file") file_Node.parm("file").set(get_Mesh_File) clean_Node = file_Node.createOutputNode("clean") clean_Node.parm("dodelgroups").set("1") clean_Node.parm("deldegengeo").set("0") partition_Node = clean_Node.createOutputNode("partition") partition_Node.parm("rule").set("$MAT") mat_assign_node = partition_Node.createOutputNode("material") prim_groups = self.get_prim_grps(partition_Node) else: file_Node = geo_node.createNode("file") file_Node.parm("file").set(get_Mesh_File) mat_assign_node = file_Node.createOutputNode("material") prim_groups = self.get_prim_grps(file_Node) # Set flags to last node mat_assign_node.setDisplayFlag(True) mat_assign_node.setRenderFlag(True) textures = self.get_Textures(get_Mesh_File_Abs) self.create_Materials(geo_node, matnet, mat_assign_node, prim_groups, textures[0], textures[1])
Example #9
Source File: tools.py From hou_farm with GNU General Public License v3.0 | 4 votes |
def get_environ_filename(path_env, name_env, path_default_list, name_default_list, parent_dir_must_exist=True, file_must_exist=True): """ Returns a filename from the current environment based on two supplied environment variable names; one for the path, one for the filename. In case the environment variables are not present or valid, you can specify a list of default paths and default filenames to check. The first valid filename will be returned. You can request that the path must exist, or that the full filename must exist. Args: path_env (str): Name of the environment variable containing the path name_env (str): Name of the environment variable containing the filename path_default_list (list): List of strings for default path name_default_list (list): List of strings for default filename parent_dir_must_exist (bool): If True, then the function will only return a filename if the path exists file_must_exist (bool): If True, then the function will only return a filename if the file exists too Returns: String: Returns a string containing the filename if the conditions are met, otherwise None """ path_list = [] name_list = [] if path_env in os.environ: path_list.append(os.environ[path_env]) if name_env in os.environ: name_list.append(os.environ[name_env]) path_list.extend(path_default_list) name_list.extend(name_default_list) for path in path_list: for name in name_list: # Use hou.expandString() on each part of the path individually. Otherwise it will remove \\ at start path = os.path.normpath("\\".join([hou.expandString(item) for item in path.split("\\")])) name = hou.expandString(name) filename = os.path.join(path, name) if file_must_exist and not (os.path.exists(filename) and os.path.isfile(filename)): continue if parent_dir_must_exist and not (os.path.exists(path) and os.path.isdir(path)): continue return filename return None # -------------------------------------------------------------------------- # Configuration File Tools # --------------------------------------------------------------------------