Python hou.selectedNodes() Examples
The following are 18
code examples of hou.selectedNodes().
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: toolbox.py From anima with MIT License | 7 votes |
def rename_selected_nodes(cls, search_str, replace_str, replace_in_child_nodes=False): """Batch renames selected nodes :param str search_str: Search for this :param str replace_str: And replace with this :return: """ import hou selection = hou.selectedNodes() for node in selection: name = node.name() node.setName(name.replace(search_str, replace_str)) if replace_in_child_nodes: for child_node in node.children(): name = child_node.name() child_node.setName(name.replace(search_str, replace_str))
Example #2
Source File: lib.py From core with MIT License | 6 votes |
def maintained_selection(): """Maintain selection during context Example: >>> with maintained_selection(): ... # Modify selection ... node.setSelected(on=False, clear_all_selected=True) >>> # Selection restored """ previous_selection = hou.selectedNodes() try: yield finally: # Clear the selection # todo: does hou.clearAllSelected() do the same? for node in hou.selectedNodes(): node.setSelected(on=False) if previous_selection: for node in previous_selection: node.setSelected(on=True)
Example #3
Source File: openFolders.py From Nagamochi with GNU General Public License v3.0 | 6 votes |
def openFolderFromSelectedNodes(ns=hou.selectedNodes()): chooselist = [] choosedict = {} for n in ns: getlist,getdict = getFolderParms(n) chooselist += getlist choosedict.update(getdict) #print choosedict,chooselist if len(chooselist)>0: choose = hou.ui.selectFromList(chooselist, message='Select Parms to bake key') for i in choose: #print str(chooselist[i]) foloderpath = choosedict[chooselist[i]] if os.path.exists(foloderpath): openFolder(foloderpath) else: print '{} is does not exists.'.format(foloderpath)
Example #4
Source File: hpastecollectionwidget.py From hpaste with GNU Lesser General Public License v3.0 | 6 votes |
def _addItem(self,collection): #Please, dont throw from here! try: nodes = hou.selectedItems() except: nodes = hou.selectedNodes() if(len(nodes)==0): QMessageBox.warning(self,'not created','selection is empty, nothing to add') return while True: #btn,(name,desc) = (0,('1','2'))#hou.ui.readMultiInput('enter some information about new item',('name','description'),buttons=('Ok','Cancel')) name, desc, public, good = QDoubleInputDialog.getDoubleTextCheckbox(self,'adding a new item to %s'%collection.name(),'enter new item details','name','description','public', '','a snippet',False) if(not good):return if(len(name)>0):break; #validity check try: #print(name) #print(desc) #print(hpaste.nodesToString(nodes)) self.model().addItemToCollection(collection,name,desc,hpaste.nodesToString(nodes),public, metadata={'nettype':self.__netType}) except CollectionSyncError as e: QMessageBox.critical(self,'something went wrong!','Server error occured: %s'%e.message)
Example #5
Source File: tools.py From hou_farm with GNU General Public License v3.0 | 6 votes |
def get_selected_rops_for_unpatching(): """ Gets a list of ROPs from the current selection that are able to be unpatched. Returns: List: A list of ROPs to unpatch """ rop_list = [] sel_nodes = list(hou.selectedNodes()) for rop_node in sel_nodes: network_type = rop_node.parent().childTypeCategory().name() if network_type == "Driver" or rop_node.type().name().startswith("rop_"): parm_tg = rop_node.parmTemplateGroup() entry = parm_tg.parmTemplates()[0] if entry.name() == "hf_orig_parms": rop_list.append(rop_node) return rop_list
Example #6
Source File: tools.py From hou_farm with GNU General Public License v3.0 | 6 votes |
def get_selected_rops_for_patching(): """ Gets a list of ROPs from the current selection that are able to be patched. Returns: List: A list of ROPs to patch """ # TODO: Need to do more checks on what is selected. Maybe allow the ROP SOP Output Driver? rop_list = [] sel_nodes = list(hou.selectedNodes()) for rop_node in sel_nodes: network_type = rop_node.parent().childTypeCategory().name() if network_type == "Driver" or rop_node.type().name().startswith("rop_"): parm_tg = rop_node.parmTemplateGroup() entry = parm_tg.parmTemplates()[0] if entry.name() != "hf_orig_parms": rop_list.append(rop_node) return rop_list
Example #7
Source File: hpaste.py From hpaste with GNU Lesser General Public License v3.0 | 5 votes |
def orderSelected(): return orderNodes(hou.selectedNodes())
Example #8
Source File: pipeline.py From core with MIT License | 5 votes |
def process(self): """This is the base functionality to create instances in Houdini The selected nodes are stored in self to be used in an override method. This is currently necessary in order to support the multiple output types in Houdini which can only be rendered through their own node. Default node type if none is given is `geometry` It also makes it easier to apply custom settings per instance type Example of override method for Alembic: def process(self): instance = super(CreateEpicNode, self, process() # Set paramaters for Alembic node instance.setParms( {"sop_path": "$HIP/%s.abc" % self.nodes[0]} ) Returns: hou.Node """ if (self.options or {}).get("useSelection"): self.nodes = hou.selectedNodes() # Get the node type and remove it from the data, not needed node_type = self.data.pop("node_type", None) if node_type is None: node_type = "geometry" # Get out node out = hou.node("/out") instance = out.createNode(node_type, node_name=self.name) instance.moveToGoodPosition() lib.imprint(instance, self.data) return instance
Example #9
Source File: hpastecollectionwidget.py From hpaste with GNU Lesser General Public License v3.0 | 5 votes |
def _replaceContent(self, index): try: nodes = hou.selectedItems() except: nodes = hou.selectedNodes() if (len(nodes)==0): QMessageBox.warning(self,'cannot replace','selection is empty') return item=index.internalPointer() good = QMessageBox.warning(self,'sure?','confirm that you want to replace the content of selected item "%s". This operation can not be undone.'%item.name() ,QMessageBox.Ok|QMessageBox.Cancel) == QMessageBox.Ok if(not good):return try: item.setContent(hpaste.nodesToString(nodes)) except CollectionSyncError as e: QMessageBox.critical(self,'something went wrong!','Server error occured: %s'%e.message)
Example #10
Source File: pdg_mutagen.py From pdg_mutagen with MIT License | 5 votes |
def setupMutationFromMarkedWedgesUI(): try: anchor_node = hou.selectedNodes()[-1] if anchor_node.type() != hou.nodeType("Top/wedge"): raise Exception("No Wedge Node selected.") except: print "No Wedge Node selected." wedge_sel_str = hou.ui.readInput("Enter Wedge Index List, i.e. '0_1,3_0,4_1'")[1] wedge_sel_list = wedge_sel_str.split(",") mode = hou.ui.selectFromList(["Convert to Takes (del. existing Takes)", "Convert to Takes (keep existing Takes)", "Convert to TOP Wedge (del. existing Takes)"], default_choices=([0]), exclusive=True, message="Please choose how to convert Marked Wedges", title="Conversion Mode", column_header="Choices", num_visible_rows=3, clear_on_cancel=True, width=400, height=180) if mode == (): raise Exception("Cancelled.") mode = mode[0] setupMutationFromMarkedWedges(wedge_sel_list, anchor_node, mode) #function to create new root wedge node from current mutagen viewer selection
Example #11
Source File: mops_tools.py From MOPS with GNU Lesser General Public License v3.0 | 5 votes |
def blackbox_definitions(out_folder): # given the selected nodes, create a blackboxed definition for each asset and save to out_folder. nodes = hou.selectedNodes() for node in nodes: definition = node.type().definition() if definition: def_filename = definition.libraryFilePath() out_file = os.path.join(out_folder, os.path.basename(def_filename)) print("saving blackboxed file: {}".format(out_file)) definition.save(file_name=out_file, template_node=node, compile_contents=True, black_box=True)
Example #12
Source File: toolbox.py From anima with MIT License | 5 votes |
def copy_node_path(cls): """copies path to clipboard """ import hou node = hou.selectedNodes()[0] hou.ui.copyTextToClipboard(node.path())
Example #13
Source File: openClSwitcher.py From Nagamochi with GNU General Public License v3.0 | 5 votes |
def run(): slnode = hou.selectedNodes()[0] if slnode.type().name()=='dopnet': uiText = 'Change OpenCL value on all children nodes in this %s' % slnode.path() value = hou.ui.displayMessage(title='OpenCL', text=uiText, buttons=("Deactive", "Active")) switchOpenCl(slnode,value)
Example #14
Source File: launchMplayFromNode.py From Nagamochi with GNU General Public License v3.0 | 5 votes |
def launch(switch): n = hou.selectedNodes()[0] if switch == False: if n.type().name() == 'ifd': run_mplay(n,'vm_picture') elif n.type().name() == 'opengl': run_mplay(n,'picture') elif n.type().name() == 'arnold': run_mplay(n,'ar_picture') elif n.type().name() == 'comp': run_mplay(n,'copoutput') elif n.type().name() == 'ris::22': run_mplay(n,'ri_display_0') elif switch == True: if n.type().name() == 'ifd': run_rv(n,'vm_picture') elif n.type().name() == 'opengl': run_rv(n,'picture') elif n.type().name() == 'arnold': run_rv(n,'ar_picture') elif n.type().name() == 'comp': run_rv(n,'copoutput') elif n.type().name() == 'ris::22': run_rv(n,'ri_display_0') # else: # hou.ui.displayMessage('Plz select Mantra ROP')
Example #15
Source File: toolbox.py From anima with MIT License | 4 votes |
def create_focus_plane(cls): """Creates a focus plane tool for the selected camera """ import hou selected = hou.selectedNodes() if not selected: return camera = selected[0] # create a grid parent_context = camera.parent() focus_plane_node = parent_context.createNode("geo", "focus_plane1") grid_node = focus_plane_node.createNode("grid") # Set orient to XZ Plane grid_node.parm("orient").set(0) # set color and alpha attr_wrangle = focus_plane_node.createNode("attribwrangle", "set_color_and_alpha") attr_wrangle.setInput(0, grid_node) attr_wrangle.parm("snippet").set("""v@Cd = {1, 0, 0}; v@Alpha = {0.5, 0.5, 0.5};""") # Create Display node display_null = focus_plane_node.createNode("null", "DISPLAY") display_null.setDisplayFlag(1) display_null.setInput(0, attr_wrangle) # Make it not renderable render_null = focus_plane_node.createNode("null", "RENDER") render_null.setRenderFlag(1) # connect the tz parameter of the grid node to the cameras focus distance focus_plane_node.setInput(0, camera) focus_plane_node.parm("tz").set(-1) camera.parm("focus").setExpression('-ch("../%s/tz")' % focus_plane_node.name()) # align the nodes from anima.env.houdini import auxiliary network_editor = auxiliary.get_network_pane() import nodegraphalign # this is a houdini module nodegraphalign.alignConnected( network_editor, grid_node, None, "down" ) nodegraphalign.alignConnected( network_editor, camera, None, "down" )
Example #16
Source File: pdg_mutagen.py From pdg_mutagen with MIT License | 4 votes |
def convertTakesToWedgeUI(): #create wedge node and add parm setup #find topnet to put wedge node in sel_node = None wedge = None try: sel_node = hou.selectedNodes()[-1] if sel_node.type() == hou.nodeType("Top/wedge"): parent = sel_node.parent() wedge = sel_node print "Selected Wedge Node: {}".format(wedge.name()) else: if sel_node.parent().type() == hou.nodeType("Object/topnet"): parent = sel_node.parent() pos = sel_node.position() print "Parent TOP Network to create Wedge Node in: {}\n".format(parent.name()) elif sel_node.type() == hou.nodeType("Object/topnet"): parent = sel_node pos = [0, 0] print "Parent TOP Network to create Wedge Node in: {}\n".format(parent.name()) #create node and set parms wedge = parent.createNode("wedge", "wedge_takes") wedge.setPosition(pos) wedge.move((0, -3)) except: print "No TOP Node, Wedge TOP, or TOPnet selected. Creating default TOPnet." parent = hou.node("obj/").createNode("topnet", "topnet_glob") wedge = parent.createNode("wedge", "wedge_takes") wedge.move((0, -3)) #call function remove_takes = False remove_takes_int = hou.ui.selectFromList(["Keep", "Remove"], default_choices=([0, ]), exclusive=True, message="Keep Takes after Conversion?", title="Convert Takes to Wedge", column_header="Choices", num_visible_rows=2, clear_on_cancel=False, width=100, height=20)[0] if remove_takes_int == 1: remove_takes = True convertTakesToWedge(wedge, remove_takes) #main non ui function
Example #17
Source File: pdg_mutagen.py From pdg_mutagen with MIT License | 4 votes |
def selectWedgeIndexUI(): #get wedge node def _isWedgeNode(node): #top_type_list = [hou.nodeType("Top/wedge"), hou.nodeType("Top/merge"), hou.nodeType("Top/ropfetch")] top_type_list = [hou.nodeType("Top/wedge")] if node.type() in top_type_list: return True else: return False node = None sel_nodes = hou.selectedNodes() if len(sel_nodes) > 0: sel_node = sel_nodes[-1] if sel_node.type() == hou.nodeType("Top/wedge"): node = sel_node else: print "No Wedge TOP selected. Please choose..." nodepath = hou.ui.selectNode(title="Select Wedge TOP Node (Last Wedge in Graph Chain)", custom_node_filter_callback=_isWedgeNode) node = hou.node(nodepath) if node == None: raise Exception("No Wedge TOP Node selected.") #enter target idx target_wdg_idx = hou.ui.readInput("Please enter Wedge Index. Example: '0_1_4'", buttons=('OK',))[1] print "\nTarget Wedge Index: " + target_wdg_idx pdgnode = node.getPDGNode() #generate static items first to be able to access node.generateStaticItems() time.sleep(1.5) work_items = pdgnode.staticWorkItems selectWedgeIndex(target_wdg_idx, node, work_items)
Example #18
Source File: toolbox.py From anima with MIT License | 4 votes |
def export_rsproxy_data_as_json(cls, geo=None, path=''): """exports RSProxy Data on points as json """ import hou if geo is None: node = hou.selectedNodes()[0] geo = node.geometry() # Add code to modify contents of geo. # Use drop down menu to select examples. pos = geo.pointFloatAttribValues("P") rot = geo.pointFloatAttribValues("rot") sca = geo.pointFloatAttribValues("pscale") instance_file = geo.pointStringAttribValues("instancefile") node_name = geo.pointStringAttribValues("node_name") parent_name = geo.pointStringAttribValues("parent_name") import os import tempfile if path == '': path = os.path.normpath( os.path.join( tempfile.gettempdir(), 'rsproxy_info.json' ) ) pos_data = [] rot_data = [] for i in range(len(pos) / 3): pos_data.append((pos[i * 3], pos[i * 3 + 1], pos[i * 3 + 2])) rot_data.append((rot[i * 3], rot[i * 3 + 1], rot[i * 3 + 2])) json_data = { "pos": pos_data, "rot": rot_data, "sca": sca, "instance_file": instance_file, "node_name": node_name, "parent_name": parent_name } import json with open(path, "w") as f: f.write(json.dumps(json_data))