Python hou.node() Examples

The following are 30 code examples of hou.node(). 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 vote down vote up
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: deadline.py    From hou_farm with GNU General Public License v3.0 6 votes vote down vote up
def submit_node_driver_geometry(rop_node, job_index, dependency_list, validate_only, batch_name=None):
    """
    Submits the Geometry ROP node to Deadline.

    Args:
        rop_node (hou.RopNode): The Geometry ROP node to submit
        job_index (int): Unique incrementing job index
        dependency_list (list of strings): List of job identifies that this job depends on
        validate_only (bool): If set to True, it will only validate the nodes and no submission will happen. 
        batch_name (str): A name to group all the similar jobs under

    Returns:
        (string, int): A tuple pair of values. The first is the job identifier, the second is the new
        value for the job index. Some nodes (IFD) submit multiple jobs, so this keeps it consistent
    """
    return submit_geometry_type_task(rop_node, job_index, dependency_list, validate_only, "sopoutput", "", batch_name) 
Example #3
Source File: lib.py    From core with MIT License 6 votes vote down vote up
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 #4
Source File: createNetworkBoxSet.py    From Nagamochi with GNU General Public License v3.0 6 votes vote down vote up
def run():
  netBoxLists = {
             #-name-:[ ---Position---- ,  -----Size------ , -----------Color------------,]
            'Camera':[hou.Vector2(5,-0), hou.Vector2(20,2),hou.Color((0.10, 0.10, 0.10)),],
             'Light':[hou.Vector2(5,-3), hou.Vector2(20,2),hou.Color((1.00, 0.98, 0.67)),],
      'Import-Stage':[hou.Vector2(5,-7), hou.Vector2(20,3),hou.Color((0.62, 0.87, 0.77)),],
        'Import-Chr':[hou.Vector2(5,-12),hou.Vector2(20,4),hou.Color((0.62, 0.77, 0.87)),],
       'Import-Prop':[hou.Vector2(5,-16),hou.Vector2(20,3),hou.Color((0.77, 0.77, 0.87)),],
              'Work':[hou.Vector2(5,-21),hou.Vector2(20,4),hou.Color((0.56, 0.10, 0.10)),],
            'Shader':[hou.Vector2(5,-24),hou.Vector2(20,2),hou.Color((0.99, 0.65, 0.65)),],
            'Render':[hou.Vector2(5,-31),hou.Vector2(20,6),hou.Color((0.57, 0.49, 0.86)),],
            }

      
  obj = hou.node('/obj')

  for nName,nAttr in netBoxLists.items():
      box = obj.createNetworkBox()
      box.setComment(nName)
      box.setName('nm_{}'.format(nName))
      box.setPosition(nAttr[0])
      box.setColor(nAttr[2])
      box.setSize(nAttr[1]) 
Example #5
Source File: createWorkGeo.py    From Nagamochi with GNU General Public License v3.0 6 votes vote down vote up
def run(pane):
	
	node = hou.node('/obj').createNode('geo','work_')
	node.setPosition(pane.cursorPosition())

	lockattrs = [
		'tx','ty','tz',
		'rx','ry','rz',
		'sx','sy','sz',
		'px','py','pz',
		'prx','pry','prz',
		'scale'
		]

	for attr in lockattrs:
		node.parm(attr).lock(True)

	node.setSelectableInViewport(False) 
Example #6
Source File: ShapeComponent.py    From gamestuff with GNU Lesser General Public License v3.0 6 votes vote down vote up
def __init__(self,gobj,shapename="light",nodelevel="/obj"):
		super(ShapeComponent,self).__init__(gobj)
		
		basenode=hou.node(nodelevel)
		self.__nodelevel=nodelevel
		self.__mynode=basenode.createNode("null","n0")
		self.__mynode.setUserData("nodeshape",shapename+"_0")
		self.__baseshape=shapename
		self.__lastShapeid=-1
		self.__shapeid=0
		self.__mynode.setUserData("nodeshape",self.__baseshape+"_0")
		self.__animated=False
		self.__animationFrame=0
		self.__lastAnimationFrame=-1
		
		self.__currentShapeName=self.__baseshape+"_0"
		
		self.update() #immediately set pos and shape 
Example #7
Source File: sop_dopsource.py    From Nagamochi with GNU General Public License v3.0 6 votes vote down vote up
def addpointvel(n,creatednodes,usevel=True):
	parent = n.parent()
	raster = toolutils.findOutputNodeOfType(n,'volumerasterizeattributes')
	inn = raster.inputs()[0]

	velocity = parent.createNode("pointvelocity")#, "get_velocity")
	if usevel:
		velocity.parm("init").set(1)
	velocity.parm("addobjectmotion").set(False)
	velocity.parm("objpath").set("`opfullpath('..')`")
	
	velocity.setInput(0,inn)
	raster.insertInput(0,velocity)
	
	visType =  hou.viewportVisualizers.types()[0]
	vis = hou.viewportVisualizers.createVisualizer(visType,category=hou.viewportVisualizerCategory.Node,node=velocity)
	vis.setIsActive(1, viewport=None)
	vis.setName('source_velocity')
	vis.setParm('style','vector')
	vis.setParm('attrib','v')
	vis.setParm('unitlength',hou.fps())
	
	creatednodes.insert(2,velocity)
	return velocity,creatednodes 
Example #8
Source File: pipeline.py    From core with MIT License 6 votes vote down vote up
def parse_container(container):
    """Return the container node's full container data.

    Args:
        container (hou.Node): A container node name.

    Returns:
        dict: The container schema data for this container node.

    """
    data = lib.read(container)

    # Backwards compatibility pre-schemas for containers
    data["schema"] = data.get("schema", "avalon-core:container-1.0")

    # Append transient data
    data["objectName"] = container.path()
    data["node"] = container

    return data 
Example #9
Source File: nmCreateFetch.py    From Nagamochi with GNU General Public License v3.0 6 votes vote down vote up
def createWedge(nName,nColor,sourcePath):
   

    outRop = hou.node('/out').createNode('wedge',nName) 
    tpl = hou.StringParmTemplate("source", "Source", 1, string_type=hou.stringParmType.NodeReference)
    outRop.addSpareParmTuple(tpl)
    outRop.setParms({
        "source"  : sourcePath,
        "prefix"  : "",
        "driver" : "`chs('source')`/To_Fetch",
        "wedgeparams" : 1,
        "random" : 0,
        })                  
    outRop.setParmExpressions({
        "range1y" : 'ch("steps1")-1',
        })
    outRop.setColor(nColor)
    return outRop 
Example #10
Source File: __init__.py    From anima with MIT License 6 votes vote down vote up
def get_shot_node(self):
        """returns or creates qLib shot node
        """
        ql_shot_node_type = "qLib::shot_ql::1"
        obj_context = hou.node("/obj")
        for child in obj_context.children():
            if child.type().name() == ql_shot_node_type:
                return child

        # so we couldn't find the shot node
        # creat a new one
        try:
            shot_node = obj_context.createNode(ql_shot_node_type)
        except hou.OperationFailed:
            return
        else:
            return shot_node 
Example #11
Source File: deadline.py    From hou_farm with GNU General Public License v3.0 6 votes vote down vote up
def handle_parms_houdini_advanced(rop_node, job_parm_dict):
    """
    Retrieves the UI Advanced Houdini/IFD parameters and inserts them into the job dictionary for submission

    Args:
        rop_node (hou.RopNode): The ROP node to retrieve the parameter values from
        job_parm_dict (dict): The dictionary to add the values to

    Returns:
        None
    """
    job_parm_dict["EnableAutoTimeout"] = rop_node.parm("hf_houdini_enable_auto_timeout").evalAsInt()
    job_parm_dict["TaskTimeoutMinutes"] = rop_node.parm("hf_houdini_task_timeout").evalAsInt()
    job_parm_dict["LimitConcurrentTasksToNumberOfCpus"] = rop_node.parm("hf_houdini_submit_limit_to_slave_limit").evalAsInt()
    job_parm_dict["ConcurrentTasks"] = rop_node.parm("hf_houdini_concurrent_tasks").evalAsInt()
    job_parm_dict["MachineLimit"] = rop_node.parm("hf_houdini_machine_limit").evalAsInt()
    job_parm_dict["LimitGroups"] = rop_node.parm("hf_houdini_limits").evalAsString()
    job_parm_dict["OnJobComplete"] = "Nothing"

    if rop_node.parm("hf_houdini_submit_machine_list_is_blacklist").evalAsInt() == 1:
        job_parm_dict["Blacklist"] = rop_node.parm("hf_houdini_machine_list").evalAsString()
    else:
        job_parm_dict["Whitelist"] = rop_node.parm("hf_houdini_machine_list").evalAsString() 
Example #12
Source File: deadline.py    From hou_farm with GNU General Public License v3.0 6 votes vote down vote up
def handle_parms_houdini(rop_node, job_parm_dict):
    """
    Retrieves the UI Houdini/IFD parameters and inserts them into the job dictionary for submission

    Args:
        rop_node (hou.RopNode): The ROP node to retrieve the parameter values from
        job_parm_dict (dict): The dictionary to add the values to

    Returns:
        None
    """
    job_parm_dict["Pool"] = rop_node.parm("hf_houdini_pool").evalAsString()
    job_parm_dict["SecondaryPool"] = rop_node.parm("hf_houdini_secondary_pool").evalAsString()
    job_parm_dict["Group"] = rop_node.parm("hf_houdini_group").evalAsString()
    job_parm_dict["Priority"] = rop_node.parm("hf_houdini_priority").evalAsInt()

    if rop_node.parm("hf_houdini_split_by").evalAsString() == "frames":
        job_parm_dict["ChunkSize"] = rop_node.parm("hf_houdini_frames").evalAsInt()
    else:
        int_seq = integer_sequence_from_deadline_range_spec(job_parm_dict["Frames"])
        min_frame, max_frame = int_seq.get_range()
        job_parm_dict["ChunkSize"] = 1 + int(float(max_frame - min_frame)/float(rop_node.parm("hf_houdini_chunks").evalAsInt())) 
Example #13
Source File: deadline.py    From hou_farm with GNU General Public License v3.0 6 votes vote down vote up
def handle_parms_submit(rop_node, job_parm_dict):
    """
    Retrieves the UI Submit parameters and inserts them into the job dictionary for submission

    Args:
        rop_node (hou.RopNode): The ROP node to retrieve the parameter values from
        job_parm_dict (dict): The dictionary to add the values to

    Returns:
        None
    """
    if rop_node.parm("hf_override_frames").evalAsInt() == 1:
        frame_str = rop_node.parm("hf_frames").evalAsString()
        job_parm_dict["Frames"] = frame_str
    else:
        min_frame = int(round(rop_node.parm("f1").evalAsFloat()))
        max_frame = int(round(rop_node.parm("f2").evalAsFloat()))
        step_by_frames = int(round(rop_node.parm("f3").evalAsFloat()))
        job_parm_dict["Frames"] = "{0}-{1}:{2}".format(min_frame, max_frame, step_by_frames) 
Example #14
Source File: samples_editor_core.py    From DMNK-Tools with MIT License 6 votes vote down vote up
def insert_light_samples(self, item, column):
        for node in lights:
            if item.text(0) == node.path():
                for i in range(len(lights[node])):
                    sample_parm = lights[node][i][0]
                    ui_samples = lights[node][i][1]

                    try:
                        amount_samples = node.parm(sample_parm).eval()
                    except:
                        amount_samples = None

                    ui_samples.setText("")
                    ui_samples.setDisabled(False)

                    if amount_samples != None:
                        ui_samples.setText(str(amount_samples))
                    else:
                        ui_samples.setDisabled(True) 
Example #15
Source File: deadline.py    From hou_farm with GNU General Public License v3.0 6 votes vote down vote up
def submit_node_button_callback(script_args):
    """
    GUI callback to submit only this node to the farm. No other dependent nodes will be submitted.
    If "hf_validate_only" parameter is set to True then it won't submit; it will only do the validation stage.
    Validation is only done for this node.

    Args:
        script_args (dict): The Houdini "kwargs" dictionary

    Returns:
        None
    """

    with RopErrorList(None) as error_list_obj:

        rop_node = script_args["node"]
        validate_only = rop_node.parm("hf_validate_only").eval() == 1

        submit_rop_list([rop_node], validate_only, error_list_obj) 
Example #16
Source File: deadline.py    From hou_farm with GNU General Public License v3.0 6 votes vote down vote up
def submit_branch_button_callback(script_args):
    """
    GUI callback to submit the node and its dependents to the farm.
    If "hf_validate_only" parameter is set to True then it won't submit; it will only do the validation stage.
    Validation is only done for this node and its dependents.

    Args:
        script_args (dict): The Houdini "kwargs" dictionary

    Returns:
        None
    """
    with RopErrorList(None) as error_list_obj:

        rop_node = script_args["node"]
        validate_only = rop_node.parm("hf_validate_only").eval() == 1

        rop_list = hou_farm_tools.get_rop_process_list(rop_node, False)
        submit_rop_list(rop_list, validate_only, error_list_obj) 
Example #17
Source File: deadline.py    From hou_farm with GNU General Public License v3.0 6 votes vote down vote up
def select_deadline_dependencies_callback(script_args):
    """
    GUI callback to select dependencies and set the appropriate parameter. It is designed to be able to be used by
    multiple parameter & button pairs. To do this, it assumes that the button has the same name as the target parm
    but with "_browse_button" on the end

    Args:
        script_args (dict): The Houdini "kwargs" dictionary

    Returns:
        None
    """
    rop_node = script_args["node"]
    target_parm_name = script_args["script_parm"].replace("_browse_button", "")
    target_parm = rop_node.parm(target_parm_name)
    result = select_deadline_dependencies(target_parm.eval())
    if result is not None:
        target_parm.set(result)


# --------------------------------------------------------------------------
# Button GUI Callbacks
# -------------------------------------------------------------------------- 
Example #18
Source File: deadline.py    From hou_farm with GNU General Public License v3.0 6 votes vote down vote up
def select_deadline_limits_callback(script_args):
    """
    GUI callback to select limits and set the appropriate parameter. It is designed to be able to be used by
    multiple parameter & button pairs. To do this, it assumes that the button has the same name as the target parm
    but with "_browse_button" on the end

    Args:
        script_args (dict): The Houdini "kwargs" dictionary

    Returns:
        None
    """
    rop_node = script_args["node"]
    target_parm_name = script_args["script_parm"].replace("_browse_button", "")
    target_parm = rop_node.parm(target_parm_name)
    result = select_deadline_limit_groups(target_parm.eval())
    if result is not None:
        target_parm.set(result) 
Example #19
Source File: deadline.py    From hou_farm with GNU General Public License v3.0 6 votes vote down vote up
def select_deadline_machine_list_callback(script_args):
    """
    GUI callback to select machines and set the appropriate parameter. It is designed to be able to be used by
    multiple parameter & button pairs. To do this, it assumes that the button has the same name as the target parm
    but with "_browse_button" on the end

    Args:
        script_args (dict): The Houdini "kwargs" dictionary

    Returns:
        None
    """
    rop_node = script_args["node"]
    target_parm_name = script_args["script_parm"].replace("_browse_button", "")
    target_parm = rop_node.parm(target_parm_name)
    result = select_deadline_machine_list(target_parm.eval())
    if result is not None:
        target_parm.set(result) 
Example #20
Source File: hpastecollectionwidget.py    From hpaste with GNU Lesser General Public License v3.0 5 votes vote down vote up
def doOnAccept(self,item):
			if(item is None):return
			try:
				try: #>h16
					hou.clearAllSelected()
				except: #<=h15.5
					hou.node("/obj").setSelected(False,clear_all_selected=True)
				hpaste.stringToNodes(item.content(), ne=self.__nepane, override_network_position=self.__savedNetworkViewPos)
			except Exception as e:
				hou.ui.displayMessage("could not paste: %s"%e.message,severity=hou.severityType.Warning) 
Example #21
Source File: deadline.py    From hou_farm with GNU General Public License v3.0 5 votes vote down vote up
def submit_node_driver_opengl(rop_node, job_index, dependency_list, validate_only, batch_name=None):
    """
    Submits the OpenGL ROP node to Deadline.
    Simply wraps a call to the Geometry ROP's submission. See submit_node_driver_geometry() for more information.
    """
    return submit_geometry_type_task(rop_node, job_index, dependency_list, validate_only, "picture", "", batch_name) 
Example #22
Source File: deadline.py    From hou_farm with GNU General Public License v3.0 5 votes vote down vote up
def submit_node_driver_baketexture(rop_node, job_index, dependency_list, validate_only, batch_name=None):
    """
    Submits the BakeTexture ROP node to Deadline.
    Simply wraps a call to the Geometry ROP's submission. See submit_node_driver_geometry() for more information.
    """
    return submit_geometry_type_task(rop_node, job_index, dependency_list, validate_only, "sopoutput", "", batch_name) 
Example #23
Source File: deadline.py    From hou_farm with GNU General Public License v3.0 5 votes vote down vote up
def submit_node_driver_dop(rop_node, job_index, dependency_list, validate_only, batch_name=None):
    """
    Submits the DOP ROP node to Deadline.
    Simply wraps a call to the Geometry ROP's submission. See submit_node_driver_geometry() for more information.
    """
    return submit_geometry_type_task(rop_node, job_index, dependency_list, validate_only, "sopoutput", "", batch_name) 
Example #24
Source File: pdg_mutagen.py    From pdg_mutagen with MIT License 5 votes vote down vote up
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 #25
Source File: deadline.py    From hou_farm with GNU General Public License v3.0 5 votes vote down vote up
def handle_parms_job(rop_node, job_parm_dict):
    """
    Retrieves the UI Job parameters and inserts them into the job dictionary for submission

    Args:
        rop_node (hou.RopNode): The ROP node to retrieve the parameter values from
        job_parm_dict (dict): The dictionary to add the values to

    Returns:
        None
    """
    job_parm_dict["Name"] = rop_node.parm("hf_job_name").evalAsString()
    job_parm_dict["Comment"] = rop_node.parm("hf_comment").evalAsString()
    job_parm_dict["Department"] = "3D" 
Example #26
Source File: ShapeComponent.py    From gamestuff with GNU Lesser General Public License v3.0 5 votes vote down vote up
def recreateHouNode(self):
		clr=self.__mynode.color()
		self.__mynode.destroy()
		self.__mynode=hou.node(self.__nodelevel).createNode("null","n0")
		self.__mynode.setColor(clr)
		self.__lastShapeid=-1
		self.__lastAnimationFrame=-1
		self.update() 
Example #27
Source File: ShapeComponent.py    From gamestuff with GNU Lesser General Public License v3.0 5 votes vote down vote up
def getHouNode(self):
		'''
		gets the visual representation - hou.Node
		please, dont destroy the node or do anything inappropriate with it
		moving it also wont work, cuz this component rewrites it's position and shape every update
		'''
		return self.__mynode 
Example #28
Source File: PlaneGameDirector.py    From gamestuff with GNU Lesser General Public License v3.0 5 votes vote down vote up
def onStart(self):
		print("trying to load level...")
		levelnode=hou.node("/obj/plane_level") #_bosstest
		if(levelnode is None):
			print("level not found")
		else:
			nodes=[x for x in levelnode.children() if x.name().find("plane_")==0]
			nodes.sort(key=lambda x: x.position()[1])
			self.__level=[(x.position(),x) for x in nodes]
			print("level loaded")
			print(self.__level)
		
		self.__globalVel=Vector2(0,-10)
		
		self.__score=GameObject("SCORE")
		self.__score.addComponent("ScoreComponent")
		self.__score.position=Vector2(10.5,9.5)
		
		self.__playerlives=GameObject("PLIVES")
		self.__playerlives.position=Vector2(11.0,8.0)
		ssc=self.__playerlives.addComponent("StackShapesComponent")
		ssc.setBaseShape("plane_plane_8")
				
		player=self.createPlayer(Vector2(0,-8))
		
		ssc.setCount(player.getComponent("PlanePlayerControl").lives())
		
		#for i in range(8):
		#	self.createEnemySimple("plane_evil01",Vector2(-4+i,9),Vector2(0,-4),2,2,i*0.1) 
Example #29
Source File: ScoreComponent.py    From gamestuff with GNU Lesser General Public License v3.0 5 votes vote down vote up
def update(self):
		gobj=self.gameObject()
		
		if(self.__rewriteNeeded):
			spareshapes=[x for x in self.__shapes]
			self.__shapes=[]
			stext=str(self.__score)
			for x in stext:
				node=None
				if(len(spareshapes)>0):
					node=spareshapes.pop(0)
				else:	
					node=hou.node(self.__nodelevel).createNode("null","score")
				
				node.setUserData("nodeshape","numbers"+x)
				self.__shapes.append(node)
				
			for shape in spareshapes:
				shape.destroy()
			self.__rewriteNeeded=False
		
		#position shapes
		pos=gobj.position
		for shape in self.__shapes:
			shape.setPosition(pos)
			pos+=hou.Vector2(0.75,0) 
Example #30
Source File: deadline.py    From hou_farm with GNU General Public License v3.0 5 votes vote down vote up
def handle_parms_mantra(rop_node, job_parm_dict):
    """
    Retrieves the UI Mantra parameters and inserts them into the job dictionary for submission

    Args:
        rop_node (hou.RopNode): The ROP node to retrieve the parameter values from
        job_parm_dict (dict): The dictionary to add the values to

    Returns:
        None
    """
    job_parm_dict["Pool"] = rop_node.parm("hf_mantra_pool").evalAsString()
    job_parm_dict["SecondaryPool"] = rop_node.parm("hf_mantra_secondary_pool").evalAsString()
    job_parm_dict["Group"] = rop_node.parm("hf_mantra_group").evalAsString()
    job_parm_dict["Priority"] = rop_node.parm("hf_mantra_priority").evalAsInt()