hou.Node class
The node() function returns a node in the scene by its path. The Node class is the base class for all Houdini nodes.
Subclasses: hou.ObjNode , hou.VopNetNode , hou.CopNode , hou.PopNetNode , hou.DopNetNode , hou.SopNode , hou.DopNode , hou.PopNode , hou.RopNode , hou.ChopNode
You cannot create instances of hou.Node by calling the constructor. You can access Node objects by getting an existing node with hou.node() or by creating a child node inside an existing node (see the hou.Node.createNode method).
n = hou.node("/obj/object1/sphere1")
The hou.node() function returns None if the given node path does not exist.
Note that a Node object internally stores a reference to the corresponding Houdini node, and that their lifetimes are different. If a Python variable referring to a Node object is deleted, the Node object will be destroyed and the Houdini node will be unaffected. Also, if you have a Node object in a Python variable and the Houdini node is deleted, the Python variable will still exist, and Python will not crash. When you call a method on the Python Node object it raises a hou.ObjectWasDeleted exception.
Methods
addNodeGroup(self, name=None)→ hou.NodeGroup-
Adds a node group to the node, and returns the new group.
If a group of the given name already exists then this function simply returns the existing group without adding a new one. If the name of the group is not specified or is an empty string, then a unique default name is automatically chosen.
This function can only be called on nodes that are networks. If it is called on a node that is not a network, then it raises
OperationFailed. addPermissions(self, permissions)addSpareParmFolder(self, folder_name, in_folder=(), parm_name=None, create_missing_folders=False)-
Adds a folder to the spare parameters.
Note that all the folders in a set correspond to one parameter. If this is the first folder to go in the set, parm_name will be used as the parameter name. Otherwise, parm_name will be ignored and the parameter name of the first folder in the set is used.
If this is the first folder in the set and parm_name is None, it will default to 'sparefolder0'. If parm_name is already in use, a unique name will be automatically generated.
If
create_missing_foldersis True, this method will create the folders in in_folder that don’t exist. So, this method can be used to add spare folders and a spare parameter at the same time.See also the
removeSpareParmFolder()andaddSpareParmTuple()methods. addSpareParmTuple(self, parm_template, in_folder=(), create_missing_folders=False)→ hou.ParmTuple-
See also the
removeSpareParmTuple()andaddSpareParmFolder()methods. allowEditingOfContents(self, propagate=False)-
Unlocks a digital asset so its contents can be edited.
To use this function, you must have permission to modify the HDA.
allSubChildren(self)→ tuple of NodesallSubChildrenOfType(self, node_type)→ tuple of NodesappendComment(self, comment)-
Appends the given text to the comment associated with this node.
asCode(self, brief=False, recurse=False, save_channels_only=False, save_creation_commands=False, save_keys_in_frames=False, save_outgoing_wires=False, save_parm_values_only=False, save_spare_parms=True, function_name=None)→str-
Prints the Python code necessary to recreate a node.
brief
Do not set values if they are the parameter’s default. Applies to the contents of the node if either recurse or save_box_contents is True.
recurse
Recursively apply to the entire operator hierarchy.
save_box_contents
Script the contents of the node.
save_channels_only
Only output channels. Applies to the contents of the node if either recurse or save_box_contents is True.
save_creation_commands
Generate a creation script for the node. If set to False (the default), the generated script assumes that the network box already exists. When set to True, the script will begin by creating the network box.
save_keys_in_frames
Output channel and key times in samples (frames) instead of seconds. Applies to the contents of the node if either recurse or save_box_contents is True.
save_parm_values_only
Evaluate parameters, saving their values instead of the expressions. Applies to the contents of the node if either recurse or save_box_contents is True.
save_spare_parms
Save spare parameters as well. When save_creation_commands is True, commands for creating spare parameters will also be output. Applies to the contents of the node if either recurse or save_box_contents is True.
function_name
If a function_name is specified, the output will be wrapped in a Python function.
asXML(self, recurse=True, output_non_default_parms=True)changeNodeType(self, new_node_type, keep_name=True, keep_parms=True, keep_network_contents=True)→ hou.Node-
Changes the node to a new type.
Keep_name,keep_parms, andkeep_network_contentsindicate that the node should keep the same name, parameter values, and contents, respectively, after its type has changed. children(self)→tupleof hou.Node-
Returns a list of nodes that are children of this node. To find the number of children nodes, use
len(node.children()).# Prints the node names of the top-level objects # in the current scene. for n in hou.node("/obj").children(): print n.name()
childrenOfType(self, node_type)→ tuple of NodeschildTypeCategory(self)→ NodeTypeCategoryclearParmAliases(self)-
Removes all alias names from parameters on the node.
collapseIntoSubnet(self, child_nodes, subnet_name=None)→ hou.Node-
Collapses the node and any specified child nodes into a subnetwork.
Any nodes in the tuple child_nodes become part of the subnetwork. However, hou.OperationFailed is raised if child_nodes contains a node that is not a child of the node on which this function is called. If subnet_name is given, the new subnet will be given that name, wherever possible.
color(self)→ hou.Color-
Returns the color of this node’s tile in the network editor.
colorRampKeys(self)→ tuple of position and color tuplescomment(self)→str-
Returns the node’s comment string.
cook(self, force=False, frame_range=())-
Asks or forces an object to re-cook.
frame_range
The frames at which to cook the object. This should be a tuple of 2 or 3 ints giving the start frame, end frame, and optionally a frame increment, in that order. If you supply a two-tuple
(start, end), the increment is1. copyNetworkBox(self, network_box_to_copy, new_name=None, channel_reference_original=False)→ hou.NetworkBox-
Copies a network box and returns the copy.
If
new_nameis given, the network box will be copied to a new network box named new_name (a different name will be generated if there’s already a network box with that name).If
channel_reference_originalisTrue, all operators created by the copy will have their animatable parameters set to reference the original operators.Raises hou.OperationFailed if this node is not a network or if the node child type does not match the network box’s node type.
createDigitalAsset(self, name=None, hda_file_name=None, description=None, min_num_inputs=None, max_num_inputs=None, compress_contents=False, comment=None, version=None, save_as_embedded=False, ignore_external_references=False)→Node-
If
file_nameisNone, it will use$HOME/houdiniX.Y/otls/OPcustom.otl. createNetworkBox(self, name=None)→ hou.NetworkBox-
Creates a network box inside this network. Raises hou.OperationFailed if this node is not a network.
If you don’t specify a
name, Houdini gives the box a default name. createNode(self, node_type_name, node_name=None, run_init_scripts=True, load_contents=True)→ hou.Node-
Creates a new node of type node_type_name as a child of this network node. Raises hou.OperationFailed if this node is not a network.
node_nameThe name of the new node. If not specified, Houdini gives the new node a default name.
run_initIf True, the initialization script associated with the node type will be run on the new node.
load_contentsIf True, any subnet contents will be loaded for custom subnet operators.
Raises hou.PermissionError if this node is inside a locked asset.
creationTime(self)→ datetime.datetimecreator(self)→ NodecreatorState(self)→strcurChild(self)deleteChild(self, child_name)deleteScript(self)→str-
Returns the script that will run when this node is deleted.
destroy(self)-
Deletes this node.
Any attempt to call methods on a
hou.Nodeinstance after it has beendestroy()-ed will raise hou.ObjectWasDeleted. digitsInName(self)→int-
Return the value of the last set of digits inside the node’s name, or 0 if there are no digits.
For example, the result is
102for a node namedgeo102, and34for a node namedlight12to34. errors(self)→str-
Returns the text of any errors from the last cook of this node, or the empty string (
"") if there were no errors. evalParm(self, parm_path)→int,float, orstr-
Evaluates the specified parameter and returns the result.
evalParmTuple(self, parm_path)→tupleofint,float, orstr-
Evaluates the specified parameter tuple and returns the result.
expressionLanguage(self)→ hou.exprLanguage enum value-
Return the node’s default expression language.
When you enter an expression in a parameter that does not already contain an expression, the node’s expression language is used to determine how that expression should be evaluated. You can change a node’s expression language in the parameter dialog in the GUI.
Changing the node’s expression language will not change the language in parameters already containing expressions (i.e. parameters with keyframes).
Note that if a parameter already contains an expression and you change that expression in the GUI, the expression language will not change, regardless of the value of the node’s expression language. To change the language of an existing expression in a parameter from Python, use hou.Parm.setExpression, as in
parm.setExpression(parm.expression(), language). extractAndDelete(self)-
Extracts the contents of a subnetwork and delete the subnetwork. The opposite of
collapseIntoSubnet().Raises hou.InvalidNodeType if this node is not a subnetwork.
extraInputs(self)→ tuple of NodesextraOutputs(self)→ tuple of NodesfileReferencePatterns(self, recurse=False, ignore_unused_subnet_branches=False)→ tuple of Parm and file_name tuplesfileReferences(self, recurse=False, ignore_unused_subnet_branches=False)→ tuple of Parm and file_name tuplesfindNetworkBox(self, name)→ hou.NetworkBox-
Return a network box with the given name inside this node, or
Noneif no network box with the given name exists. findNetworkBoxes(self, pattern)→tupleof hou.NetworkBox-
Return a list of network boxes inside this node whose names match a pattern.
findNodes(self, pattern)→ tuple of NodesfindParms(self, pattern)→ tuple of Parmsglob(self, pattern)→ tuple of NodeshdaModule(self)→ hou.HDAModule-
Returns the
HDAModuleobject for this node’s type. If the node is not an instance of a digital asset, the module is empty. Otherwise, the module contents will be the user-defined “Python Module” section in the digital asset. hide(self, on)indirectInputs(self)→tupleof hou.SubnetIndirectInput-
Returns the hou.SubnetIndirectInput objects of a subnet.
Raises hou.InvalidNodeType if this node is not a subnetwork.
info(self, verbose=False)→strinputAncestors(self)→tupleof hou.Node-
Returns a tuple of all input ancestors of this node. If include_ref_inputs is False, then reference inputs are not traversed. If follow_subnets is True, then instead of treating subnetwork nodes as a single node, we also traverse its children starting with its display node.
See also the
inputs()method. inputConnections(self)→ tuple of hou.NodeConnection-
Returns a list of NodeConnection objects for the nodes connected this node’s inputs.
To get a list of the connected nodes themselves, use the
inputs()method. inputConnectors(self)→ tuple of tuple of NodeConnectionsinputs(self)→tupleof hou.Node-
Returns a list of the nodes connected to this node’s inputs.
insertInput(self, input_index, node_to_become_input, output_index=0) OR insertInput(self, input_index, indirect_to_become_input)isCurrent(self)→bool-
Returns True if the node is the “current” node.
isHidden(self)isInsideLockedHDA(self)→bool-
Returns whether this node is inside a locked digital asset. If this node is not inside a locked HDA, the node may deviate from the OTL definition.
isLocked(self)→bool-
Returns whether or not this HDA instance is locked. If this node is unlocked, it may deviate from the OTL definition.
isNetwork(self)isSelected(self)→bool-
Returns whether this node is selected.
layoutChildren(self, child_nodes=[], horizontal_spacing=-1, vertical_spacing=-1)loadOldStylePresetsFile(self, presets_file_name)loadPresets(self, presets)matchCurrentDefinition(self)-
Syncs the contents of this node with its type definition.
For subnet types that were saved with their contents locked, you can use this command to replace the contents of node with the contents of the operator type. The parameters of the node are not modified, only the contents.
matchesCurrentDefinition(self)→bool-
Returns whether the contents of the node match its type definition.
matchesDefinition(self)modificationTime(self)→ datetime.datetimemove(self, vector2)-
Moves this node’s tile in the network editor graph by the increments in the given hou.Vector2. To position a node absolutely, use
setPosition(). To get the node’s current graph position, useposition().Raises hou.InvalidInput if the node cannot move to the position specified.
moveToGoodPosition(self, relative_to_inputs=True, move_inputs=True, move_outputs=True, move_unconnected=True)→ hou.Vector2-
Moves a node to a well-spaced position near its inputs or outputs and returns the new position of the node.
name(self)→str-
Returns this node’s name.
networkBoxes(self)→ tuple of hou.NetworkBox-
Return a list of the network boxes inside this node.
node(self, node_path)→ hou.Node orNone-
Returns the node at the given path, where a relative path is resolved relative to this node.
For example, to get the parent node of a node in the the variable “n”, use
n.node(".."). To get a child node named"geo5", usen.node("geo5"). To get a sibling node named"light3", usen.node("../light3").Note that the return value may be an instance of a subclass of Node. For example, if the node being found is an object node, the return value will be a hou.ObjectNode.
nodeGroup(self, name)→ hou.NodeGroup-
Returns a node group contained by the node with the given name, or
Noneif the group does not exist. nodeGroups(self)→ tuple of hou.NodeGroup-
Returns the list of node groups in this node.
outputConnections(self)→ tuple of hou.NodeConnection-
Returns NodeConnection objects for the nodes connected to this node’s outputs. To get a list of the nodes themselves, use
outputs(). outputConnectors(self)→ tuple of tuple of NodeConnectionsoutputs(self)→ tuple of Nodesparent(self)→ hou.Node-
Returns the network node that contains this node.
parm(self, parm_path)→ hou.Parm orNone-
Returns the parameter at the given path, or
Noneif the parameter doesn’t exist. parmAliases(self, recurse=False)→ dict of hou.Parm tostr-
Returns a dictionary of parameter aliases on the node’s parameters. The keys in the dictionary are the parameters that have aliases and the values are the alias names.
recurse
Return the parameter aliases for this node and its children.
parms(self)→tupleof hou.Parm-
Returns a list of the parameters on this node.
parmsInFolder(self, folder_names, folder_style)→tupleof hou.Parm-
Returns a list of parameters in a folder on this node. Returns all parameters in the folder and its subfolders (if any).
folder_names
A sequence of folder name strings. For example, to get a list of the parameters in the Shading folder of the Render folder, use
("Render", "Shading").If this sequence is empty, the method returns all parameters on the node, the same as if you called
parms().folder_style
A member of hou.folderType describing how the folder is rendered.
Raises hou.OperationFailed if the folder specified by
folder_namesdoes not exist.See also hou.Parm.containingFolders and hou.Parm.containingFolderSetParmTuples
parmToNodeReferences(self, max_hierarchy_depth=None)→dictof hou.Parm to hou.NodeparmTuple(self, parm_path)→ hou.ParmTuple orNone-
Returns the parm tuple at the given path, or
Noneif it doesn’t exist.This method is similar to
parm(), except it returns a hou.ParmTuple instead of a hou.Parm. parmTuples(self)→tupleof hou.ParmTuple-
Returns a list of all parameter tuples on this node.
This method is similar to
parms(), except it returns a list of hou.ParmTuple instead of hou.Parm. parmTuplesInFolder(self, folder_names)→ tuple of hou.ParmTuple-
Returns a list of the parameter tuples in a folder on this node. This method is similar to
parmsInFolder(), except it returns a list of hou.ParmTuple instead of hou.Parm. SeeparmsInFolder()above for information about the arguments.See also hou.Parm.containingFolders and hou.Parm.containingFolderSetParmTuples
path(self)→str-
Returns the path of this node in the network.
permissions(self)→intpickedChildren(self)→ tuple of NodespickedChildrenRecursively(self, keep_same_node_type_category=True)→tupleof hou.Nodeposition(self)→ hou.Vector2-
Returns the position of this node’s tile in the network editor graph as a
Vector2. See alsomove()andsetPosition(). referencedNodes(self, max_hierarchy_depth=None)→ tuple of NodesrelativePathTo(self, base_node)→str-
Returns a relative path to base_node from this node.
removeColorRampKey(self, position)removePermissions(self, permissions)removeSpareParmFolder(self, folder)-
Removes an empty folder from the spare parameters.
folderis a sequence of folder names. So, to remove the Output folder, use("Output",)instead of"Output".See also
addSpareParmFolder(). removeSpareParmTuple(self, parm_tuple)-
Removes the specified spare parameter tuple.
See also
addSpareParmTuple(). reorderChildrenAfter(self, children_nodes, after_node=None)reorderChildrenBefore(self, children_nodes, before_node=None)reorderChildrenToBeginning(self, children_nodes)reorderChildrenToEnd(self, children_nodes)runInitScripts(self)-
Runs the initialization script associated with this node’s type.
saveCompiledCookCodeToFile(self, file_name)-
Saves compiled VEX code to a disk file (on nodes that support this).
saveCookCodeToFile(self, file_name, skip_header=False)-
Saves VEX/RSL source code to a disk file (on nodes that support this).
saveDefinition(self, ignore_external_references=False)saveOldStylePresetsFile(self, presets_file_name)savePresets(self, presets_name, dir_name=None)→ NodeParmPresetsselectedChildren(self, include_hidden = False)→tupleof hou.Node-
Return a list of selected nodes that are children of this node. The current node is always the last selected node.
The
include_hiddenparameter controls whether or not hidden nodes can be returned, even if they are selected.The following example will print the names of all selected objects in
/obj:for n in hou.node("/obj").selectedChildren(): print n.name()
To find the total number of children nodes, use
len(node.selectedChildren()). sessionId(self)setColor(self, color)-
Sets the color of this node’s tile in the network editor to the given hou.Color.
setColorRampKey(self, position, color)setComment(self, comment)-
Sets the comment associated with this node. See also
appendComment(). setCreatorState(self, state)setCurrent(self, on, clear_all_selected=False)-
Sets or unsets this node as the “current” node, optionally deselecting all other selected nodes.
setDeleteScript(self, script_text, language=hou.scriptLanguage.Python)-
Sets the script that will run when this node is deleted.
setExpressionLanguage(self, language)-
Set the node’s default expression language. See
expressionLanguage()for more information. setFirstInput(self, node_to_become_input, output_index=0) OR setFirstInput(self, indirect_to_become_input)setInput(self, input_index, node_to_become_input, output_index=0) OR setInput(self, input_index, indirect_to_become_input)setName(self, name, unique_name = False)-
Sets the name of this node. Raises hou.InvalidNodeName if the new name contains characters other than letters, numbers, periods, dashes, or underscores. Raises hou.OperationFailed if the node could not be renamed (for example, another node already exists with the name, the node is the root node or top-level manager, or the node is inside a locked asset). If the unique_name parameter is set to True, the supplied name may be changed to ensure that it doesn’t match the name of any existing node.
setNextInput(self, node_to_become_input, output_index=0) OR setNextInput(self, indirect_to_become_input)setPermissions(self, permissions)setPosition(self, vector2)-
Sets the position of this node’s tile in the network editor graph. Raises hou.InvalidInput if the node cannot have the given position.
setSelected(self, on, clear_all_selected=False)-
Selects or deselects this node, optionally deselecting all other selected nodes.
showFloatingDetailsViewWindow(self)showFloatingParmWindow(self)size(self)→ hou.Vector2-
Returns the size of this node’s tile in the network editor graph as a
Vector2. spareParms(self)→ tuple of hou.Parm-
Returns a list of the spare (user-defined) parameters on this node.
stampValue(self, parm_name, default_value)subpathUpToNonSubnet(self)type(self)→ hou.NodeType-
Returns the
NodeTypeobject for this node. For example, all camera nodes share the same node type. unsetInput(self, input_index)warnings(self)→str-
Returns the text of any warnings from the last cook of this node, or the empty string (
"") if there were no warnings. _getArgumentAutoComplete(self, method_name, arguments)→ tuple ofstr__eq__(self, node)→bool-
Implements
==betweenNodeobjects.For example, hou.root() == hou.node(“/”) will return
True.There can be multiple Python
Nodeobjects for the same Houdini node. Two identical calls tohou.node()will return different PythonNodeobjects, with each representing the same Houdini node. Comparing these nodes using==(which calls__eq__) will returnTrue, while comparing them usingis(the object identity test) will return false.You can compare a node to
None. This behavior is useful becausehou.node()returnsNoneif the node doesn’t exist. Comparing an node to anything other than another node orNoneraisesTypeError. __getitem__(self, parm_name)__ne__(self, node)→bool-
Implements
!=betweenNodeobjects. See__eq__().