Inheritance |
|
Methods ¶
Shader Information ¶
shaderName(as_otl_path=True, shader_type_name=None)
→ str
Returns the name of the shader defined by this VOP (if it is an embedded
shader) or the shader name defined by the shop in which this VOP resides.
If as_otl_path
is True,
returns an opdef:
path to the SHOP type. The shader_type_name
is
a string indicating the shader context type to use; some nodes may provide
several shader types, and each may have a different name. This is applicable
only to multi-context shader nodes, such as a vopnet material shop.
shaderNameForSignature(signature=None)
→ str
Returns the name of the shader given the node’s signature.
Different VOP signatures may have different shader function names,
so this method will return the shader name for the signature given in the
parameter. If the signature
is not provided, the current signature of the
node is used.
shaderCode(shader_type=hou.shaderType.Surface)
→ str
Returns the generated VEX or RSL code for this VOP, using the given shader type to control output context. If the VOP is a subnet that can be packaged up as an encapsulated shader, then the specific code to define an encapsulated shader is output. Otherwise, the code generated for the entire VOP network is output.
shaderLanguageName()
→ str
Returns the name of the language the shader is written in.
setShaderLanguageName(language_name)
→ bool
Sets the shader language for this node. Returns true on success, but false if the given language was not found and could be set for the node.
In the majority of cases, VOP nodes deduce their language from the operator render mask, shader generator, or the parent, so this function is not called too often. However, occasionally, it is necessary to override the implicit deduction, usually for built-in operators such as a subnet or a parameter VOP.
renderMask()
→ str
Returns the mask for renderers for which the node represents a valid shader.
shaderString(render_type=None, shader_type=hou.shaderType.Surface, as_encapsulated=False)
→ str
Returns the string that encodes the shader name and parameter values suitable for specifying as a shader assignment in an input stream acceptable by the renderer of a given type. If the VOP is material that provides a few shader contexts (eg, surface and displacement), it is necessary to provide the shader type explicitly. If as_encapsulated is true, the returned shader string will encode the shader as embedded in the parent shader with parameters referencing the parent, if needed.
code()
→ str
Returns the VEX or RSL code that defines this node.
outerCode()
→ str
Returns the outer code associated with this node.
Inputs and Outputs ¶
inputDataTypes()
→ tuple of str
Returns a tuple of all input data types for this node. Data types for input connectors that are hidden are also included.
The strings returned by this method can be used to set the Type parameter on a Parameter or Constant VOP.
isInputGroupExpanded(group)
→ bool
Returns True
if the group with the name specified by group
is expanded
in the Network View. The group
parameter should be a value returned
by the hou.VopNode.inputGroupName method. Returns the current
expanded state of the group even if the group is not currently visible
due to the setting of the input/output detail flags. Returns True
if the
group name is not valid.
inputGroupNames()
→ tuple of str
Returns the names of the input groups on this VOP Node. Note that not all groups will contain any inputs, and so not all groups will be visible in the Network View. Use the hou.VopNode.inputsInGroup method to determine which inputs are part of a particular group.
inputsInGroup(group)
→ tuple of int
Returns the input index values of all inputs that appear in the group with
the name specified in group
. This parameter should be a value returned
by the hou.VopNode.inputGroupName method. This method returns the
same set of inputs whether the group is expanded or collapsed. Returns an
empty tuple if the group name contains no inputs or is not a recognized
group name.
inputIndexOrder()
→ tuple of int
Return a tuple of integers which represent input index numbers that can be passed to hou.Node.setInput and related functions. The order of the index numbers represents the order in which those inputs appear in the network view tile for this object. This ordering is affected by the way inputs are grouped together on the parameter pane for this node.
outputDataTypes()
→ tuple of str
Returns a tuple of all output data types for this node. Data types for output connectors that are hidden are also included.
The strings returned by this method can be used to set the Type parameter on a Parameter or Constant VOP.
subnetTerminalChild(output_name)
→ tuple of houNode and str
Returns a tuple of a node and its input name that corresponds to the subnet output connector by the given name.
setInputGroupExpanded(group, expanded)
Sets the expanded state of the input group with the name specified by the
group
parameter. This controls the appearance of this input group in the
Network View. Pass a group value of None
to expand or collapse all input
groups.
isInputCompatible(idx, other, other_idx, allow_conversions = False) ->
bool`
Return True
if input idx
of this object can be connected to output
other_idx
of node other
. Two inputs can be connected if they are of
the same data type. If the allow_conversions
parameter is set to True
,
a more permissive check is done which accepts an input connection if the
output data type can be automatically converted to the input data type
without an explicit conversion node (such as a float output to a vector
input).
findBypassInputName(output_name)
→ str
Returns the name of an input to which the given output pipes thru when the node’s bypass flag is turned on.
Controlling Input Nodes ¶
insertParmGenerator(input_name, parm_gen_type, reference_input_defaults)
→ hou.VopNode
Creates a parameter or a constant node and wires it into an input
specified by input_name on this node. parm_gen_type
must be a value of
hou.vopParmGenType. If reference_input_defaults
is True, this node
will reference the defaults of the newly created node.
A resultant parameter or constant node is returned.
insertParmGeneratorsForAllInputs(parm_gen_type, reference_input_defaults)
→ dict of str
to hou.VopNode
Creates parameter or constant nodes and wires them into unconnected inputs
on this node. parm_gen_type
must be a value of
hou.vopParmGenType. If reference_input_defaults
is True, then
this node will reference the defaults of the newly created nodes.
A dictionary is returned with input names for keys and hou.VopNode objects for values.
deleteIndependentInputNodes(input_index):, make_parm_node, reference_input_defaults)
→ bool
Deletes a chain of nodes wired into a particular input if and only if they are wired only into the specified input on this node. Returns true if nodes were deleted, false otherwise.
setIsInputVisible(input_name, is_visible)
Shows or hides an input connector of this node. The input is specified by input_name. The connector is shown if is_visible is True, and hidden otherwise.
isInputVisible(input_name)
→ bool
Returns True if the input connector specified by input_name on this node is visible, False otherwise.
Flags ¶
setDebugFlag(on)
Turns the node’s debug flag on or off.
The value of the on
argument must be True or False.
Raises hou.PermissionError if the node is unwritable.
isDebugFlagSet()
→ bool
Returns True if the node’s debug flag is turned on. Returns False otherwise.
setDetailLowFlag(on)
Turns on or off the low detail flag for this node’s inputs and outputs.
With this flag turned on, all inputs and outputs to this node will appear
in the network view as connecting to a single location on the node. This
flag does not affect the operation of this node, only its appearance in
the network view. The value of the on
argument must be True or False.
Raises hou.PermissionError if the node is unwritable.
isDetailLowFlagSet()
→ bool
Returns True if the node’s low detail flag is turned on. Returns False otherwise.
setDetailMediumFlag(on)
Turns on or off the medium detail flag for this node’s inputs and outputs.
With this flag turned on, only connected inputs and outputs to this node
will be visible in the network view. This flag does not affect the
operation of this node, only its appearance in the network view. The value
of the on
argument must be True or False.
Raises hou.PermissionError if the node is unwritable.
isDetailMediumFlagSet()
→ bool
Returns True if the node’s medium detail flag is turned on. Returns False otherwise.
setDetailHighFlag(on)
Turns on or off the high detail flag for this node’s inputs and outputs.
With this flag turned on, all inputs and outputs to this node will appear
in the network view, whether they are connected to another node or not.
This flag does not affect the operation of this node, only its appearance
in the network view. The value of the on
argument must be True or False.
Raises hou.PermissionError if the node is unwritable.
isDetailHighFlagSet()
→ bool
Returns True if the node’s high detail flag is turned on. Returns False otherwise.
bypass(on)
Turns the node’s bypass flag on or off. When the bypass flag is
on, the node will have no effect on the scene. The value of the
on
argument must be True or False.
Raises hou.PermissionError if the node is unwritable.
isBypassed()
→ bool
Returns True if the node’s bypass flag is turned on. Returns False otherwise.
setCompressFlag(on)
Turns the node’s compress flag on or off. If the compress flag is True,
this node will not show a preview image in the Network View. If the
compress flag is False, a preview image will be shown in the Network View.
The value of the on
argument must be True or False.
Raises hou.PermissionError if the node is unwritable.
isCompressFlagSet()
→ bool
Returns True if the node’s compress flag is turned on. Returns False otherwise. The compress flag controls whether or not a preview image is shown for this node in the Network View.
setMaterialFlag(on)
Turns the node’s material flag on or off. If the material flag is True, it indicates that this node is meant to be used as a material to be assigned to objects or geometry. It will appear in material node choosers and be saved to IFDs generated with the option to save all materials turned on.
Raises hou.PermissionError if the node is unwritable.
isMaterialFlagSet()
→ bool
Returns True if the node’s material flag is turned on. Returns False otherwise. The material flag indicates whether this node is intended for use as a material to be assigned to objects or geometry.
extraBindings()
→ tuple of str
Returns the list of extra bindings the VOP node would add to the generated code. Implemented specifically for Snippet VOPs, this allows one to determine what bindings will be created by any adhoc @ references.
usdShaderParms(force_parms_at_default=False)
→ tuple of str
Returns the list of shader parameter names whose values need to be authored on the USD shader primitive. This list includes node parameters that are designated as shader parameters and are active, but are not at default values (unless they have a tag forcing it to be translated).
If force_parms_at_default
is True, returns shader parameters that
are at default values too; excludes them otherwise, which is a default
behaviour.
usdPreviewShaderParms()
→ tuple of str
Returns the list of shader parameter names whose values are used to author a standard USD preview shader. Usually, these parameters are tagged with a special “ogl_*” spare data.
Other ¶
currentSignatureName()
→ str
Returns the current signature name of this node. The HDA nodes may provide several valid signatures, and this function returns the name of the currently used signature. A signature is defined by a set of input types and each set is assigned a name.
parmDefinerNode()
→ hou.VopNode
Return the Parameter VOP node that defines the parameter that this node is bound to. This method only applies to Parameter VOP nodes.
Return None if this node is not a Parameter VOP or if this node is the definer node.
Methods from hou.NetworkItem ¶
networkItemType()
→ hou.networkItemType
Return an enum value indicating what type of network item is represented
by this object. This value is equivalent to using the isinstance
built in
Python function with the matching class
(for example hou.networkItemType.Connection is equivalent to
hou.NodeConnection).
Methods from hou.NetworkMovableItem ¶
name()
→ str
Return this node’s name. See also hou.NetworkMovableItem.path.
setName(name, unique_name=False)
Set the name of this node. Raises hou.OperationFailed 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 (e.g. /obj), 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.
digitsInName()
→ 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 102
for a node named geo102
, and 34
for
a node named light12to34
.
path()
→ str
Return the full path (i.e. starting with /
) of this node in the network.
relativePathTo(base_node)
→ str
Return a relative path to another node object from this node.
>>> box1 = hou.node("/obj/box_object1/box1") >>> sphere1 = hou.node("/obj/sphere_object1/sphere1") >>> box1.relativePathTo(sphere1) '../../sphere_object1/sphere1' >>> hou.node("/obj").relativePathTo(box1) 'box_object1/box1' >>> box1.relativePathTo(box1) '.'
parent()
→ hou.Node
Return the node that contains this item.
Note that this method returns None if the item is the root node (i.e. /
).
>>> hou.node("/obj/box_object1").parent() <hou.Node at /obj> >>> print hou.node("/").parent() None
parentNetworkBox()
→ hou.NetworkBox or None
Returns the parent network box which contains this item, or None if it is not inside a network box.
isSelected()
→ bool
Return whether this item is selected.
See also hou.selectedNodes().
isPicked()
→ bool
Equivalent to calling hou.NetworkMovableItem.isSelected.
setSelected(on, clear_all_selected=False, show_asset_if_selected=False)
Select or deselect this item, optionally deselecting all other selected
items in this network. If show_asset_if_selected
is True, and this item
is a Node
, then the panes will show the top-level asset of the selected
item instead.
setPicked(on)
Equivalent to calling hou.NetworkMovableItem.setSelected with default values for all optional parameters.
color()
→ hou.Color
Return the color of this item’s tile in the network editor.
setColor(color)
Sets the color of this item’s tile in the network editor to the given hou.Color.
sessionId()
Returns an integer value that uniquely identifies this item
in a given Houdini session. This id is only guaranteed to be unique
in a single Houdini process. It is useful as a quick and easy way to
save a restore a reference to an item. It is also only unique for
a specific item subclass. So there may be a Node
with the same
session id as a NetworkBox
.
See hou.nodeBySessionId() to turn a session id back into a node, or hou.networkBoxBySessionId() to turn a session id back into a network box, or more generally, hou.itemBySessionId() to turn a session id combined with an enum value indicating the item subclass into an item of that type.
position()
→ hou.Vector2
Return the position of this item’s tile in the network editor graph as
a Vector2
. See also move()
and setPosition()
.
setPosition(vector2)
Sets the position of this item’s tile in the network editor graph. Raises hou.InvalidInput if the item cannot have the given position.
move(vector2)
Moves this item’s tile in the network editor graph by the increments in the given hou.Vector2.
To position a item absolutely, use setPosition()
.
To get the item’s current graph position, use position()
.
Raises hou.InvalidInput if the item cannot move to the position specified.
shiftPosition(vector2)
Equivalent to calling hou.NetworkMovableItem.move.
size()
→ hou.Vector2
Return the size of this item’s tile in the network editor graph as a
Vector2
.
Methods from hou.Node ¶
node(node_path)
→ hou.Node or None
Return the node at the given path, or None if no such node exists. If
you pass in a relative path (i.e. the path does not start with /
),
searches are performed relative to this node.
For example, to get the parent node of a node in the variable n
, use
n.node("..")
. To get a child node named geo5
, use n.node("geo5")
.
To get a sibling node named light3
, use n.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.ObjNode instance.
If the path is an absolute path (i.e. it starts with /
), this
method is a shortcut for hou.node(node_path)
. Otherwise, it is
a shortcut for hou.node(self.path() + "/" + node_path)
. See also
hou.node().
nodes(node_path_tuple)
→ tuple
of hou.Node or None
This is like node() but takes multiple paths and returns multiple Node objects. This is the equivalent of:
nodes = [self.node(path) for path in paths]
item(item_path)
→ hou.NetworkMovableItem or None
Return the network item at the given path, or None if no such item exists.
If you pass in a relative path (i.e. the path does not start with /
),
searches are performed relative to this node.
If the path is an absolute path (i.e. it starts with /
), this
method is a shortcut for hou.item(node_path)
. Otherwise, it is
a shortcut for hou.item(self.path() + "/" + item_path)
. See also
hou.item().
Note that the return value may be an instance of a subclass of NetworkMovableItem. For example, if the item being found is an object node, the return value will be a hou.ObjNode instance. If the item is a network box, the return value will be a hou.NetworkBox instance.
items(item_path_tuple)
→ tuple
of hou.NetworkMovableItem or None
This is like item() but takes multiple paths and returns multiple NetworkMovableItem objects. This is the equivalent of:
items = [self.item(path) for path in paths]
isNetwork()
→ bool
Return True
if this node is a network, in other words a node that may
contain child nodes. Otherwise return False
which indicates that several
other methods such as hou.Node.createNode will raise
hou.OperationFailed if they are called.
isEditable()
→ bool
If this node is not an HDA and not inside an HDA, this method returns True.
If this node is an HDA node, returns True if the node is unlocked,
False if it is locked (this is equivalent to
not node.matchesCurrentDefinition()
).
If this node is inside a locked HDA node, this method returns True if this node is or is inside an editable subnet within the locked HDA. Otherwise it returns False.
This method reflects the ability of certain types of modifications to be
made to the children of this node. These modifications, such as wiring
nodes together, or setting flags are edits to the child nodes which also
affect the behavior of the parent or surrounding nodes. For example, to
determine if a node can have its display flag turned on, you would test
node.parent().isEditable()
. For modifications to a node that are purely
internal to the node itself, such as modifying a parameter value, you
should test if node.isEditableInsideLockedHDA()
.
children()
→ tuple
of hou.Node
Return a list of nodes that are children of this node. Using the file system analogy, a node’s children are like the contents of a folder/directory.
To find the number of children nodes, use len(node.children())
.
The order of the children in the result is the same as the user defined ordering in Houdini. To see this order, switch the network view pane into list mode, and ensure that the list order is set to user defined. To reorder nodes, drag and drop them in the list.
def pc(node): '''Print the names of the children of a particular node. This function can be handy when working interactively in the Python shell.''' for child in node.children(): print child.name() def ls(): '''Print the names of the nodes under the current node.''' pc(hou.pwd())
The following expression evaluates to a list of children of a particular node type:
[c for c in node.children() if c.type() == node_type]
allItems()
→ tuple
of hou.NetworkMovableItem
Return a tuple containing all the children of this node.
Unlike children
, this method will also return
hou.NetworkBox, hou.SubnetIndirectInput,
hou.StickyNote, and hou.NetworkDot objects.
allSubChildren(top_down=True, recurse_in_locked_nodes=True, sync_delayed_definition=False)
→ tuple of hou.Node
Recursively return all sub children of this node. For example,
hou.node("/").allSubChildren()
will return all the nodes in the hip
file.
top_down
If True, this function will do a top-down traversal, placing a node in the returned tuple before its children. If False, it will do a bottom-up traversal, placing children before their parents.
recurse_in_locked_nodes
If True, the function will recurse inside locked child nodes
(child nodes for which the isEditable()
method returns False
)
and include children of the locked child nodes in the returned tuple.
If False, the function will not recurse inside locked children nodes, and children of the locked child nodes will not be included in the returned tuple. (The locked child nodes, however, will be included.)
For example if ‹recurse_in_locked_nodes› is True
and
hou.node("/obj/geo1")
contains a Platonic Solids node (a locked node),
then the tuple returned by hou.node("/obj").allSubChildren()
will include the Platonic Solids node and its child nodes. If
‹recurse_in_locked_nodes› is False
, the returned tuple will
contain the Platonic Solids node, but not its child nodes.
sync_delayed_definition
The contents of nodes may some times not be loaded until the
node is evaluated. To avoid expanding all nodes unnecessarily,
by default these are left un-expanded so the contents will
not be returned. Setting ‹sync_delayed_definition› to True
will recursively sync all children, fully instantiating the
entire network, and returning all the synced nodes.
Note that a tuple is returned, not a generator. This means that it is safe to delete or create nodes while looping through the return value.
The following function deletes all children of a particular type that appear anywhere inside a given node:
def removeSubChildrenOfType(node, node_type): '''Recursively delete all children of a particular type.''' for child in node.allSubChildren(): if child.type() == node_type: child.destroy()
This code, for example, removes all the visibility SOPs anywhere under /obj:
>>> removeSubChildrenOfType(hou.node("/obj"), hou.sopNodeTypeCategory().nodeTypes()['visibility'])
allSubItems(top_down=True, recurse_in_locked_nodes=True, sync_delayed_definition=False)
→ tuple of hou.NetworkMovableItem
Recursively return all sub items (nodes, network boxes, sticky notes, etc.)
in this node. For example, hou.node("/").allSubItems()
will return all
the node network items in the hip file.
Refer to hou.Node.allSubChildren for more information on the method parameters.
allNodes()
→ generator of hou.Node
Recursively return a sequence of all nodes contained in this node including this node. This method differs from hou.Node.allSubChildren in the following ways:
-
It includes this node in the returned sequence.
-
It does not guarantee a top-down or bottom-up traversal order.
-
The method is a generator and does not return a tuple so it is not safe to create or delete nodes while looping through the return value.
Here is an example of printing out the paths for all nodes under /obj:
root_node = hou.node("/obj") for node in root_node.allNodes(): print node.path()
glob(pattern, ignore_case=False)
→ tuple of hou.Node
Return a tuple of children nodes name matches the pattern.
The pattern may contain multiple pieces, separated by spaces. An asterisk
(*
) in a pattern piece will match any character. By default, Houdini
will add the nodes from each pattern piece to those already matched.
However, if the pattern piece begins with a caret (^
), Houdini will
remove the matches for that piece from the result.
By default the pattern match is case-sensitive. Set ignore_case
to
True for case-insensitive pattern matching. Note that case insensitivity
only applies when matching node names. It does not apply when matching
group, network box or bundle names.
This method returns an empty tuple if you pass in an empty pattern.
>>> obj = hou.node("/obj") >>> obj.createNode("geo", "geo1") <hou.ObjNode of type geo at /obj/geo1> >>> obj.createNode("geo", "geo2") <hou.ObjNode of type geo at /obj/geo2> >>> obj.createNode("geo", "grid") <hou.ObjNode of type geo at /obj/grid> >>> obj.createNode("geo", "garbage") <hou.ObjNode of type geo at /obj/garbage> >>> obj.createNode("geo", "box") <hou.ObjNode of type geo at /obj/box> >>> def names(nodes): ... return [node.name() for node in nodes] >>> names(obj.glob("g*")) ['geo1', 'geo2', 'grid', 'garbage'] >>> names(obj.glob("ge* ga*")) ['geo1', 'geo2', 'garbage'] >>> names(obj.glob("g* ^ga*")) ['geo1', 'geo2', 'grid']
See also hou.Node.recursiveGlob.
recursiveGlob(pattern, filter=hou.nodeTypeFilter.NoFilter, include_subnets=True)
→ tuple of hou.Node
Like hou.Node.glob, return a tuple of children nodes whose name matches the pattern. However, any matching child will have all its children added, recursively. As well, the result may be filtered by node type.
Houdini first matches children nodes against the pattern, then recursively adds the subchildren of matching children, and then applies the filter.
pattern
Child node names will be matched against this string pattern.
See hou.Node.glob and hou.NodeBundle for information about the pattern syntax.
Note that if a child node matches the pattern and include_subnets
is True
, all of its subchildren will be added to the result (subject to filtering), regardless of the pattern.
filter
A hou.nodeTypeFilter enumeration value to limit matched nodes to a particular type (e.g. object nodes, geometry object nodes, surface shader SHOPs, etc.).
include_subnets
Specifies whether the children of a matching node will also be returned, regardless of the pattern.
The pattern and filter behavior is very similar to that used by node bundles in Houdini. See hou.NodeBundle for more information.
Raises hou.OperationFailed if the pattern is invalid.
createNode(node_type_name, node_name=None, run_init_scripts=True, load_contents=True, exact_type_name=False, force_valid_node_name=False)
→ hou.Node
Create a new node of type node_type_name
as a child of this node.
node_name
The name of the new node. If not specified, Houdini appends a number to the node type name, incrementing that number until a unique node name is found. If you specify a name and a node already exists with that name, Houdini will append a number to create a unique name.
run_init_scripts
If True, the initialization script associated with the node type will be run on the new node.
load_contents
If True, any subnet contents will be loaded for custom subnet operators.
exact_type_name
If True, the node’s type name will be exactly as specified in the
node_type_name
. Otherwise, a preferred operator type that matches
the given node_type_name
may be used. For example, the given “hda”
may match a newer version “hda::2.0”, or if there are two available
operators “namespaceA::hda” and “namespaceB::hda”, and the “namespaceB”
has precedence, then the created node will be of type “namespaceB::hda”.
force_valid_node_name
If True, then create a new node with a valid name even if
node_name
is invalid. For example, if node_name
is
=foo bar=, then the new node name becomes =foo_bar=. If
force_valid_node_name
is False and node_name
is invalid,
then raise a hou.OperationFailed exception.
Raises hou.OperationFailed if the given node name is invalid and
force_valid_node_name
is False.
Raises hou.OperationFailed if this node cannot contain children.
Raises hou.PermissionError if this node is inside a locked asset.
>>> obj = hou.node("/obj") # Let Houdini choose a name based on the node type name. >>> obj.createNode("geo") <hou.ObjNode of type geo at /obj/geo1> # Let Houdini choose a unique name. >>> obj.createNode("geo") <hou.ObjNode of type geo at /obj/geo2> # Give the node a specific name. >>> obj.createNode("geo", "foo") <hou.ObjNode of type geo at /obj/foo> # Let Houdini create a unique name from our suggested name. Also, don't # run the geometry object init scripts so the contents are empty. >>> obj.createNode("geo", "geo1", run_init_scripts=False) <hou.ObjNode of type geo at /obj/geo3> >>> obj.node("geo1").children() (<hou.SopNode of type file at /obj/geo1/file1>,) >>> obj.node("geo3").children() ()
destroy(disable_safety_checks=False)
Delete this node.
If you call methods on a Node instance after it has been destroyed, Houdini will raise hou.ObjectWasDeleted.
Raises hou.OperationFailed if you try to delete a node inside a locked asset.
When disable_safety_checks
is True
, this disables safety checks that
might otherwise crash Houdini when this method is called while nodes are
cooking.
copyItems(items, channel_reference_originals = False, relative_references = True, connect_outputs_to_multi_inputs = True)
→ tuple
of hou.NetworkMovableItem
Create copies of all specified items in this network. The items do not need to be children of this network, but all items must be contained in the same parent network.
If channel_reference_originals
is True, the parameters of all new nodes
are set to channel reference the original nodes. If a copied node is a
sub-network, only the top level node establishes channel references to the
original. Child nodes inside the sub-network will be simple copies of the
original child nodes. The relative_references
parameter controls whether
the channel references use relative or absolute paths to the source nodes.
If connect_outputs_to_multi_inputs
is True, and any items being copied
have outputs connected to a multi-input node (like a Merge), then the new
item copies will also be connected to the multi-input node. Normally
copied nodes do not have any outputs to nodes outside the copied set.
Returns a tuple
of all the new network items.
Raises hou.OperationFailed if this node cannot contain children. Raises hou.PermissionError if this node is inside a locked asset.
deleteItems(items, disable_safety_checks=False)
Destroys all the items in the provided tuple of
hou.NetworkMovableItem objects. This is significantly more efficient
than looping over the items and calling destroy()
on each one. It also
safely handles cases where one object may not be allowed to be deleted
unless another object is also deleted.
Raises hou.OperationFailed if one or more of the provided items is not a child of this node. Raises hou.PermissionError if this node is or is inside a locked digital asset.
When disable_safety_checks
is True
, this disables safety checks that
might otherwise crash Houdini when this method is called while nodes are
cooking.
canCreateDigitalAsset()
→ bool
Return True
if hou.Node.createDigitalAsset can succeed.
isCurrent()
→ bool
Return a boolean to indicate of the node is the last selected node in its network.
Each network (i.e. node containing children) stores its own list of selected nodes, and the last selected node has special meaning. For example, it is the node displayed in unpinned parameter panes.
See also hou.selectedNodes() to get a tuple of all the selected nodes in all networks in Houdini. The last node in this list also has special meaning in Houdini, and corresponds to the global current node.
setCurrent(on, clear_all_selected=False)
Set or unset this node as the last selected one.
Each network (i.e. node containing children) stores its own list of selected nodes, and the last selected node has special meaning. For example, it is the node displayed in unpinned parameter panes.
If on
is True, this node will become the last selected node. If it
is False and this node was the last selected one, it will be unselected
and the second-last selected node will become the last selected node.
If clear_all_selected
is true, Houdini will unselect every node in
this network before performing the operation.
See also hou.Node.setSelected and hou.selectedNodes().
selectedChildren(include_hidden=False, include_hidden_support_nodes=False)
→ tuple
of hou.Node
Return a tuple containing the children of this node that are selected. Note that the last selected node has special meaning, and can also be retrieved with hou.Node.isCurrent.
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 selected children nodes, use
len(node.selectedChildren())
.
selectedItems(include_hidden=False, include_hidden_support_nodes=False)
→ tuple
of hou.NetworkMovableItem
Return a tuple containing the children of this node that are selected.
Unlike selectedChildren
, this method will also return any selected
hou.NetworkBox, hou.SubnetIndirectInput,
hou.StickyNote, and hou.NetworkDot objects.
The following example will print the positions of all selected items in
/obj
:
for n in hou.node("/obj").selectedItems(): print n.position()
numItems(item_type=None, selected_only=False, include_hidden=False)
→ int
Return the number of children of this node that are selected and are of
the type specified by item_type
.
item_type
If None
, the total number of selected items of any type is returned.
If a hou.networkItemType value is provided, the number of
selected items of that type is returned.
selected_only
If True
, only selected items are counted.
type()
→ hou.NodeType
Return the hou.NodeType object for this node.
For example, all camera node instances share the same node type.
childTypeCategory()
→ hou.NodeTypeCategory
Return the hou.NodeTypeCategory corresponding to the children of this node. For example, if this node is a geometry object, the children are SOPs. If it is an object subnet, the children are objects.
inputs()
→ tuple
of hou.Node
Return a tuple of the nodes connected to this node’s inputs. If an input is connected to a hou.SubnetIndirectInput, the node connected to the corresponding input on the parent subnet is returned. In other words the presence of the indirect input is hidden. This means the resulting nodes may not all be siblings of the calling node.
If a particular input is not connected (or is connected to an indirect
input and the corresponding subnet parent input is not connected), a
None
value is placed in the tuple at that location.
input(inputidx)
→ hou.Node
Return the node connected to specified input of this node. If an input is connected to a hou.SubnetIndirectInput, the node connected to the corresponding input on the parent subnet is returned. In other words the presence of the indirect input is hidden. This means the resulting nodes may not all be siblings of the calling node.
If the input is not connected (or is connected to an indirect
input and the corresponding subnet parent input is not connected), a
None
value is returned.
inputFollowingOutputs(inputidx)
→ hou.Node
Return the node connected to specified input of this node. If an input is connected to a hou.SubnetIndirectInput, the node connected to the corresponding input on the parent subnet is returned. In other words the presence of the indirect input is hidden. This means the resulting nodes may not all be siblings of the calling node.
In addition, if the input is connected to a non-primary output in SOPs, the returned node will be the node inside of the SOP network rather than the subnet itself. This can be used for code that doesn’t understand multiple outputs as it will attempt to resolve the node whose first output matches the input of this node.
If the input is not connected (or is connected to an indirect
input and the corresponding subnet parent input is not connected), a
None
value is returned.
outputs()
→ tuple
of hou.Node
Return a tuple of the nodes connected to this node’s outputs.
This method is a shortcut for [connection.outputNode() for connection in
self.outputConnections()]
.
inputConnections()
→ tuple
of hou.NodeConnection
Returns a tuple of hou.NodeConnection objects for the connections coming into the top of this node. The tuple will have a length equal to the number of connections coming into the node. Returns an empty tuple if nothing is connected to this node.
To get a list of the connected nodes themselves, use hou.Node.inputs. To get a list of all possible connection sites (whether or not anything is connected to them), use hou.Node.inputConnectors.
>>> cookie = hou.node("/obj").createNode("geo").createNode("cookie") >>> cookie.setInput(1, cookie.parent().createNode("box")) >>> cookie.inputConnections() (<hou.NodeConnection from grid1 output 0 to cookie input 1>,) >>> cookie.inputConnectors() ((), (<hou.NodeConnection from grid1 output 0 to cookie input 1>,))
See also hou.Node.inputConnectors.
outputConnections()
→ tuple
of hou.NodeConnection
Return a tuple of NodeConnection objects for the connections going out of the bottom of this node. If nothing is wired into the output of this node, return an empty tuple.
To get a list of the connected nodes themselves, use hou.Node.outputs.
Note that this method is a shortcut for: reduce(lambda a, b: a+b,
self.outputConnectors(), ())
. Since most nodes have only one output
connector, though, this method is usually equivalent to
self.outputConnectors()[0]
.
>>> box = hou.node("/obj").createNode("geo").createNode("box") >>> box.parent().createNode("xform").setFirstInput(box) >>> box.parent().createNode("subdivide").setFirstInput(box) >>> box.outputConnections() (<hou.NodeConnection from box1 output 0 to xform1 output 0>, <hou.NodeConnection from box1 output 0 to subdivide1 input 0>)
See also hou.node.outputConnectors.
inputConnectors()
→ tuple
of tuple
of hou.NodeConnection
Return a tuple of tuples of hou.NodeConnection objects. The length of the result tuple is equal to the maximum number of inputs that can be connected to this node. Each subtuple contains exactly one node connection if something is wired into the connector; otherwise it is the empty tuple.
See also hou.NodeConnection and hou.Node.inputConnections.
outputConnectors()
→ tuple
of tuple
of hou.NodeConnection
Return a tuple of tuples of hou.NodeConnection objects. The length of the result tuple is equal to the number of output connectors on this node. Each subtuple contains all the connections going out of that connector, and is empty if nothing is wired to that connector.
>>> split = hou.node("/obj").createNode("dopnet").createNode("split") >>> split.parent().createNode("rbdsolver").setFirstInput(split) >>> split.parent().createNode("gravity").setFirstInput(split, 1) >>> split.parent().createNode("merge").setFirstInput(split, 1) >>> split.outputConnectors() ((<hou.NodeConnection from split1 output 0 to rbdsolver1 input 0>,), (<hou.NodeConnection from split1 output 1 to gravity2 input 0>, <hou.NodeConnection from split1 output 1 to merge1 input 0>), (), ())
See also hou.NodeConnection and hou.Node.outputConnections.
indirectInputs()
→ tuple
of hou.SubnetIndirectInput
Return the hou.SubnetIndirectInput objects of a subnet.
Raises hou.InvalidNodeType if this node is not a subnetwork.
subnetOutputs()
→ tuple
of hou.Node
Return the child output nodes of a subnetwork.
Certain networks, such as SOPs, have special Output nodes to override the canonical Display or Render nodes and allow multiple outputs. If any output nodes are present, this returns a list of those nodes. If no output nodes are present, either the display or render node is returned depending on if the target of cooking is the display or an output driver. If the node has no children, an empty list is returned.
inputAncestors(include_ref_inputs=True, follow_subnets=False, only_used_inputs=False)
→ tuple
of hou.Node
Return 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. If only_used_inputs is True, we only traverse nodes that were involved in the last cook.
See also the inputs()
method.
inputIndex(input_name)
Obtains an index of a node input that has the given name.
For the node categories that use input names, it returns the index of the input with the given name. For VOP nodes, the name may also be a node parameter name that has a corresponding input.
outputIndex(output_name)
Obtains an index of a node output that has the given name.
For the node categories that use input names, it returns the index of the output with the given name.
setInput(input_index, item_to_become_input, output_index=0)
If item_to_become_input
is not None, connect the output connector of
another node to an input connector of this node. Otherwise, disconnect
anything connected to the input connector.
input_index
The index of this node’s input connector.
item_to_become_input
If None
this method disconnects everything from the input connector.
If a hou.Node or a hou.SubnetIndirectInput, this method
connects its output to this node’s input connector.
output_index
The index of the other node’s output connector.
Raises hou.InvalidInput if output_index
is invalid. Raises
hou.OperationFailed if item_to_become_input
is not in the same
network as this node. Raises hou.PermissionError if the node is
inside a locked asset.
setNamedInput(input_name, item_to_become_input, output_name_or_index)
Connects an input on this node, specified by input_name, to an output on the item_to_become_input, specified by either an output name or an an output index.
setFirstInput(item_to_become_input, output_index=0)
A shortcut for self.setInput(0, item_to_become_input)
. See
hou.Node.setInput for more information.
setNextInput(item_to_become_input, output_index=0, unordered_only=False)
Connect the output connector from another node into the first unconnected
input connector or a multi-input connector of this node. If a node has
some ordered inputs followed by a multi-input connector, the
unordered_only
parameter can be used to force the input to connect to
the unordered multi-input connection instead of any of the ordered input
which may not be connected.
This method is roughly equivalent to:
for input_index, connectors in enumerate(self.inputConnectors()): if len(connectors) == 0: self.setInput(input_index, item_to_become_input, output_index) raise hou.InvalidInput("All inputs are connected")
Raises hou.InvalidInput if all inputs are connected. See hou.Node.setInput for more information.
insertInput(input_index, item_to_become_input, output_index=0)
Insert an input wire. In other words, for each input connector after input_index, shift the contents of that input connector to the next one, and then call hou.Node.setInput. See hou.Node.setInput for the meanings of the parameters.
numOrderedInputs()
→ int
Some nodes can have a small number of dedicated inputs with specific
meanings, followed by an arbitrary number of additional inputs, where
gaps are not permitted between the inputs (these are referred to as
unordered inputs). This is common in DOP nodes such as the
Multiple Solver DOP. This function returns the
number of dedicated (or ordered) inputs that occur before the unordered
inputs begin. This function will only return non-zero values if the
hou.NodeType.hasUnorderedInputs function for this node’s
hou.Node.type object returns True
.
createInputNode(input_index, node_type_name, node_name=None, run_init_scripts=True, load_contents=True, bool exact_type_name=False)
Create a new node and connect it to one of this node’s inputs. Return the new node.
input_index
The index of this node’s input connector.
node_type_name
The name of the type of node to create. See the createNode method for more information.
node_name
See the createNode method for more information.
run_init_scripts
See the createNode method for more information.
load_contents
See the createNode method for more information.
exact_type_name
See the createNode method for more information.
See also the createOutputNode method.
createOutputNode(node_type_name, node_name=None, run_init_scripts=True, load_contents=True, bool exact_type_name=False)
Create a new node and connect its first input to this node’s (first) output. Return the new node.
See the createNode method for more information on the parameters.
See also the createInputNode method.
inputNames()
→ tuple of str
Returns a tuple of all input names for this node. Names for input connectors that are hidden are also included.
inputLabels()
→ tuple of str
Returns a tuple of all input labels for this node. Labels for input connectors that are hidden are also included.
outputNames()
→ tuple of str
Returns a tuple of all output names for this node.
outputLabels()
→ tuple of str
Returns a tuple of all output labels for this node.
editableInputStrings(input_index)
→ dict
of str
to str
Return a dictionary of the string key/value pairs associated with the specified input index. The purpose of these strings may vary from one node type to another.
This method will raise an exception if the node type does not use this feature. Use hasEditableInputData to determine if a node type supports editable input data.
editableInputString(input_index, key)
→ str
Return the string associated with the specified input index and key. The purpose of this string may vary from one node type to another.
This method will raise an exception if the node type does not use this feature. Use hasEditableInputData to determine if a node type supports editable input data.
setEditableInputString(input_index, key, value)
Sets a string value associated with the specified input index and key. The purpose of this string may vary from one node type to another.
This method will raise an exception if the node type does not use this feature. Use hasEditableInputData to determine if a node type supports editable input data.
isSubNetwork()
→ bool
Return True if the node is a sub-network and False otherwise.
collapseIntoSubnet(child_nodes, subnet_name=None, subnet_type=None)
→ hou.Node
Given a sequence of children nodes of this node, collapse them into a subnetwork. In other words, create a subnet inside this node’s network and move the specified children of this network inside that subnet.
child_nodes
The children nodes of this node that will go in the new subnet.
subnet_name
The name for the new subnet node, or None if you want Houdini to automatically choose a name.
subnet_type
The type for the new subnet node, or None if you want Houdini to automatically choose a primary subnetwork type, which is recommended.
Raises hou.OperationFailed if a node inside child_nodes
is not
a child of this network, or if child_nodes
is an empty sequence.
This example function takes a single node and replaces it with a subnet, moving the node into the subnet..
def collapseSingleNodeIntoSubnet(node, subnet_name=None): node.parent().collapseIntoSubnet((node,), subnet_name=None)
extractAndDelete()
→ tuple
of hou.NetworkMovableItem
Move the children of this subnet node to become siblings of this node, and
then delete this node. The method is the opposite of
collapseIntoSubnet()
. Returns a tuple containing all extracted items.
Raises hou.InvalidNodeType if this node is not a subnetwork.
comment()
→ str
Return the node’s comment string.
setComment(comment)
Sets the comment associated with this node.
See also appendComment()
.
appendComment(comment)
Appends the given text to the comment associated with this node.
isDisplayDescriptiveNameFlagSet()
→ bool
Return a boolean to indicate of the node should display its descriptive name in the network editor.
setDisplayDescriptiveNameFlag(on)
Set or unset whether this node should display its descriptive name in the network editor.
creator()
→ Node
Returns the first parent of different type from this node. For simple networks this will be the same as parent(), but if the parent is the same node type, eg, both are SOPs, the process is repeated until a different type is found. This is useful for finding the container node, for example, the Object that a SOP is in, without having to worry about nested SOP networks. Note that SOPs do not always have Objects as parents, however!
moveToGoodPosition(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.
layoutChildren(items=(), horizontal_spacing=-1.0, vertical_spacing=-1.0)
Automatically position all or some children of this node in the network editor.
items
A sequence of child hou.NetworkMovableItem objects to position. This may include nodes, dots, and/or subnet inputs. If this sequence is empty, this method will reposition all child items of this node.
horizontal_spacing
A fraction of the width and height of a tile that affects the space between nodes with common inputs. If this parameter is -1, Houdini uses the default spacing.
vertical_spacing
A fraction of the width and height of a tile that affects the space between a node and its output nodes. If this parameter is -1, Houdini uses the default spacing.
isHidden()
Return whether the node is hidden in the network editor. Note that Houdini also uses the term “exposed” to refer to nodes that are not hidden.
If a visible node is connected to a hidden node, the network editor will display dashed lines for the wire going from the visible node to the hidden node.
See also hou.Node.hide.
hide(on)
Hide or show a node in the network editor. See hou.Node.isHidden for more information about hidden nodes.
errors()
→ tuple
of str
Return the text of any errors from the last cook of this node, or an empty tuple if there were no errors.
warnings()
→ tuple
of str
Return the text of any warnings from the last cook of this node, or an empty tuple if there were no warnings.
messages()
→ tuple
of str
Return the text of any messages from the last cook of this node, or an empty tuple if there were no messages.
networkBoxes()
→ tuple of hou.NetworkBox
Return a list of the network boxes inside this node.
iterNetworkBoxes()
→ generator of hou.NetworkBox
Return a generator that iterates through all the network boxes inside this node.
findNetworkBox(name)
→ hou.NetworkBox
Return a network box with the given name inside this node, or None
if
no network box with the given name exists.
findNetworkBoxes(pattern)
→ tuple
of hou.NetworkBox
Return a list of network boxes inside this node whose names match a pattern.
createNetworkBox(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.
Network box names are not displayed in the network editor pane. Instead, a “comment” can be specified with the hou.NetworkBox.setComment method, and this comment will appear in the title bar of the network box.
copyNetworkBox(network_box_to_copy, new_name=None, channel_reference_original=False)
→ hou.NetworkBox
Copies a network box and returns the copy.
If new_name
is given, the network box will be copied to a new network box
named new_name (a different name will be generated if there is already a
network box with that name).
If channel_reference_original
is True
, 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.
stickyNotes()
→ tuple of hou.StickyNote
Return a list of the sticky notes inside this node.
iterStickyNotes()
→ generator of hou.StickyNote
Return a generator that iterates through all the sticky notes inside this node.
findStickyNote(name)
→ hou.StickyNote
Return a sticky note with the given name inside this node, or None
if
no sticky note with the given name exists.
findStickyNotes(pattern)
→ tuple
of hou.StickyNote
Return a list of sticky notes inside this node whose names match a pattern.
createStickyNote(name=None)
→ hou.StickyNote
Creates a sticky note inside this network. Raises hou.OperationFailed if this node is not a network.
If you don’t specify a name
, Houdini gives the note a default name.
copyStickyNote(network_box_to_copy, new_name=None)
→ hou.StickyNote
Copies a sticky note and returns the copy.
If new_name
is given, the sticky note will be copied to a new sticky note
named new_name (a different name will be generated if there is already a
sticky note with that name).
Raises hou.OperationFailed if this node is not a network or if the node child type does not match the sticky note’s node type.
createNetworkDot()
→ hou.NetworkDot
Creates a network dot inside this network. Raises hou.OperationFailed if this node is not a network.
networkDots()
→ tuple
of hou.NetworkDot
Returns a tuple of all dots in this network.
copyItemsToClipboard(items)
Given a sequence of child items (nodes, network boxes, sticky notes, etc), save them to the clipboard so they can be pasted into this or another network.
items
A sequence of hou.NetworkMovableItems that are children of this node.
Raises hou.OperationFailed if any of the nodes or network boxes are node children of this node. Raises hou.PermissionError if you do not have permission to read the contents of this node.
pasteItemsFromClipboard(position = None)
Load the contents of a file saved with hou.Node.copyItemsToClipboard
into the contents of this node. If the position
parameter is given as a
tuple of two float values (or equivalent, like a hou.Vector2), the
pasted items are moved such that they are centered around the provided
position.
Raises hou.OperationFailed if this node is not a network, or if there are errors loading the items from the clipboard. Raises hou.PermissionError if this node is a locked instance of a digital asset.
__eq__(node)
→ bool
Implements ==
between Node
objects.
For example, hou.root() == hou.node(“/”) will return True
.
There can be multiple Python Node
objects for the same Houdini node.
Two identical calls to hou.node()
will return different Python Node
objects, with each representing the same Houdini node. Comparing these nodes
using ==
(which calls __eq__
) will return True
, while comparing them
using is
(the object identity test) will return False
.
__ne__(node)
→ bool
Implements !=
between Node
objects. See __eq__()
.
setUserData(name, value)
Add/set a named string on this node instance.
name
A unique name (key) for the user-defined data. By using different names, you can attach multiple pieces of user-defined data to a node.
value
The string to store.
This name/value pair is stored with the hip file and is included in the output from opscript and hou.Node.asCode.
The following example illustrates how to set, access, and delete user-defined data:
>>> n = hou.node("/obj").createNode("geo") >>> n.setUserData("my data", "my data value") >>> n.userData("my data") 'my data value' >>> n.userDataDict() {'my data': 'my data value'} >>> n.destroyUserData("my data") >>> n.userDataDict() {} >>> print n.userData("my data") None
See per-node user-defined data for more information and examples.
Tip
If you prefix a user data key with nodeinfo_
, the key (without the prefix) and the value will be shown as a custom field in the node info popup window.
userDataDict()
→ dict
of str
to str
Return a dictionary containing all the user-defined name/string pairs for this node.
See hou.Node.setUserData for more information.
userData(name)
→ str
or None
Return the user-defined data with this name, or None
if no data with this
name exists.
See hou.Node.setUserData for more information.
This method can be implemented as follows:
def userData(self, name): return self.userDataDict().get(name)
destroyUserData(name, must_exist=True)
Remove the user-defined data with this name.
See hou.Node.setUserData for more information.
Raises hou.OperationFailed if no user data with this name exists and must_exist is True.
clearUserDataDict()
Remove all user-defined data.
See hou.Node.setUserData for more information.
isFlagReadable(flag)
→ bool
Return True if the specified flag is readable and False otherwise.
flag
must be a hou.nodeFlag value.
isFlagWritable(flag)
→ bool
Return True if the specified flag is writable and False otherwise.
flag
must be a hou.nodeFlag value.
isGenericFlagSet(flag)
→ bool
Returns the value of the specific flag.
flag
must be a hou.nodeFlag value.
setGenericFlag(flag, value)
Sets the value of the specified flag based on the bool
value
argument.
flag
must be a hou.nodeFlag value.
Methods from hou.OpNode ¶
createOrMoveVisualizer(output_index)
Creates a node for visualizing the data from a particular output of this
node. If a visualizer node already exists in the current network, it is
moved and connected to the specified output_index
. This method is only
implemented for SOP and VOP nodes. Other node types do nothing when
this method is called.
copyTo(destination_node)
→ hou.Node
Copy this node to a new place in the node hierarchy. The new node is placed inside the given destination node. This method returns the new node.
Raises hou.OperationFailed if the destination node cannot contain the new node. Raises hou.PermissionError if the destination node is inside a locked asset.
parm(parm_path)
→ hou.Parm or None
Return the parameter at the given path, or None
if the parameter
doesn’t exist.
globParms(pattern, ignore_case=False, search_label=False, single_pattern=False)
→ tuple of hou.Parm
Return a tuple of parameters matching the pattern.
The pattern may contain multiple pieces, separated by spaces. An asterisk
(*
) in a pattern piece will match any character. By default, Houdini
will add the parameters from each pattern piece to those already matched.
However, if the pattern piece begins with a caret (^
), Houdini will
remove the matches for that piece from the result.
By default the pattern match is case-sensitive. Set ignore_case
to
True for case-insensitive pattern matching. Note that case insensitivity
only applies when matching node and parameter names. It does not apply
when matching group, network box or bundle names.
By default, only parameters with names matching the pattern are returned. Set search_label
to True to also return parameters with labels matching the pattern.
If single_pattern
is True, the pattern will be treated as one pattern even if there are spaces in the pattern.
This method returns an empty tuple if you pass in an empty pattern.
evalParm(parm_path)
→ int
, float
, or str
Evaluates the specified parameter and returns the result.
parms()
→ tuple
of hou.Parm
Return a list of the parameters on this node.
parmsReferencingThis()
→ tuple
of hou.Parm
Return a list of the parameters that reference this node.
allParms()
→ generator of hou.Parm
Recursively return a sequence of all the parameters on all of the nodes contained in this node including this node.
This method is a generator and does not return a tuple.
Here is an example of printing out the parameter paths for all nodes under /obj:
root_node = hou.node("/obj") for parm in root_node.allParms(): print parm.path()
setParms(parm_dict)
Given a dictionary mapping parm names to values, set each of the corresponding parms on this node to the given value in the dictionary.
The following example sets the tx
and sy
parameters at once:
>>> node = hou.node("/obj").createNode("geo") >>> node.setParms({"tx": 1, "sy": 3})
The names are tried against both parameters and parmameter tuples, so the base name can also be used:
>>> node = hou.node("/obj").createNode("geo") >>> node.setParms({"t": (1, 2, 3), "s": (3, 3, 3)})
Raises hou.OperationFailed if any of the parameter names are not valid.
See also the setParmExpressions method.
setParmsPending(parm_dict)
Given a dictionary mapping parm names to values, sets the pending value of each of the corresponding parms on this node. Supports both parameters and parameter tuples.
Raises hou.OperationFailed if any of the parameter names are not valid.
See also the setPending method.
setParmExpressions(parm_dict, language=None, replace_expressions=True)
Given a dictionary mapping parm names to expression strings, set each of the corresponding parms on this node to the given expression string in the dictionary.
See hou.Parm.setExpression for a description of the language
and
replace_expressions
parms.
The following example expressions set the tx
and sy
parameters at once:
>>> node = hou.node("/obj").createNode("geo") >>> node.setParmExpressions({"tx": 'ch("ty")', "sy": "sin($F)"})
Raises hou.OperationFailed if any of the parameter names are not valid.
See also the setParms method.
parmTuple(parm_path)
→ hou.ParmTuple or None
Return the parm tuple at the given path, or None
if it doesn’t exist.
This method is similar to parm()
, except it returns a
hou.ParmTuple instead of a hou.Parm.
evalParmTuple(parm_path)
→ tuple
of int
, float
, or str
Evaluates the specified parameter tuple and returns the result.
parmTuples()
→ tuple
of hou.ParmTuple
Return 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.
parmsInFolder(folder_names)
→ tuple
of hou.Parm
Return 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")
. Note that by folder name, we mean the label
used in the parameter dialog, not the internal parameter name.
If this sequence is empty, the method returns all parameters on the
node, the same as if you called parms()
.
Raises hou.OperationFailed if the folder specified by folder_names
does not exist.
For example, suppose a node had a Render folder that contained a Shading subfolder. Then this line of code would return the parameters in the Render folder:
# Note the trailing comma after "Render" to tell Python that "Render" is # contained in a tuple/sequence as opposed to just a single string with # parentheses around it. >>> node.parmsInFolder(("Render", ))
And this line of code would return the parameters in the Shading subfolder.
>>> node.parmsInFolder(("Render", "Shading"))
See also hou.Parm.containingFolders and hou.Parm.containingFolderSetParmTuples
Note that this method does not work for multi-parameters, which behave similar to folder parameters. To get a list of parameters in a multi-parameter, call hou.Parm.multiParmInstances.
parmTuplesInFolder(folder_names)
→ tuple of hou.ParmTuple
Return 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. See parmsInFolder()
above for information about the arguments.
See also hou.Parm.containingFolders and hou.Parm.containingFolderSetParmTuples
expressionLanguage()
→ 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)
.
setExpressionLanguage(language)
Set the node’s default expression language.
See expressionLanguage()
for more information.
parmAliases(recurse=False)
→ dict of hou.Parm to str
Return 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.
clearParmAliases()
Removes all alias names from parameters on the node.
spareParms()
→ tuple of hou.Parm
Return a list of the spare (user-defined) parameters on this node.
removeSpareParms()
Removes all spare parameters from this node.
parmTemplateGroup()
→ hou.ParmTemplateGroup
Return the group of parm templates corresponding to the current parameter layout for this node.
You can edit the parameter layout for this node (add or remove spare parameters, reorder or hide built-in parameters, etc.) by getting the current parameter group, modifying it, and calling hou.Node.setParmTemplateGroup with it.
The following example creates a geometry object, adds a My Parms
folder
to it, and adds a My Parm
float parameter to it in that folder. The
parameters are added only to the geometry object created; other geometry
objects are unaffected.
>>> node = hou.node("/obj").createNode("geo") >>> group = node.parmTemplateGroup() >>> folder = hou.FolderParmTemplate("folder", "My Parms") >>> folder.addParmTemplate(hou.FloatParmTemplate("myparm", "My Parm", 1)) >>> group.append(folder) >>> node.setParmTemplateGroup(group)
See hou.ParmTemplateGroup and the setParmTemplateGroup method for more information and examples.
setParmTemplateGroup(parm_template_group, rename_conflicting_parms=False)
Change the spare parameters for this node.
parm_template_group
A hou.ParmTemplateGroup object containing the new parameter layout.
rename_conflicting_parms
If True
, parameters in the group with the same parm tuple names will
be automatically renamed. If False
and there are parms with the same
name, this method raises hou.OperationFailed.
Note that each node type has a set of parameters which must exist and must be of certain types. If your parm template group does not contain the required parameters for the node type the will be added at the bottom and will be made invisible. Similarly, if your parm template group attempts to modify the type, range, label, or other property of a required parameter, all changes to that parameter other than visibility settings will be ignored.
This method is preferred over the other parameter-related methods in this class (addSpareParmTuple, removeSpareParmTuple, replaceSpareParmTuple, addSpareParmFolder, removeSpareParmFolder) because it lets you more easily make manipulate parameters.
See hou.HDADefinition.setParmTemplateGroup to change the parameter interface of a digital asset.
addSpareParmTuple(parm_template, in_folder=(), create_missing_folders=False)
→ hou.ParmTuple
Add a spare parameter tuple to the end of the parameters on the node. If
in_folder
is not an empty sequence, this method adds the parameters to
the end of the parameters in a particular folder.
parm_template
A hou.ParmTemplate subclass instance that specifies the type of parameter tuple, the default value, range, etc.
in_folder
A sequence of folder names specifying which folder will hold the
parameter. If this parameter is an empty sequence (e.g. ()
), Houdini
will not put the parameter inside a folder. If it is, for example,
("Misc", "Controls")
, Houdini puts it inside the “Controls” folder
that’s inside the “Misc” folder. If it is, for example, ("Misc",)
,
Houdini puts it inside the “Misc” folder.
create_missing_folders
If True, and the folder location specified by in_folder
does not
exist, this method creates the missing containing folders.
Note that this method can add a single folder by passing a
hou.FolderParmTemplate for parm_template
.
See also the removeSpareParmTuple()
and addSpareParmFolder()
methods.
This method is deprecated in favor of setParmTemplateGroup
.
removeSpareParmTuple(parm_tuple)
Removes the specified spare parameter tuple.
See also addSpareParmTuple()
.
This method is deprecated in favor of setParmTemplateGroup
.
addControlParmFolder(folder_name=None, parm_name=None)
Adds a control parameter folder as the front-most folder at the top-level.
This is used to increase visibility of customized control parameters. If a
folder of the same name already exists, no new folder will be created.
If folder_name
is None, it will be set as 'Controls'. If parm_name
is None,
it will be set as 'folder'.
If there are no current folders present, the existing parameters will be grouped together and stored into a new folder named 'Parameters' and placed after the new control parameter folder.
addSpareParmFolder(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_folders
is 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.
Note that you can add folders by passing a hou.FolderParmTemplate
to the addSpareParmTuple
method, so this method is deprecated. Note
also that addSpareParmTuple
is deprecated in favor of
setParmTemplateGroup
.
See also the removeSpareParmFolder
and addSpareParmTuple
methods.
This method is deprecated in favor of setParmTemplateGroup
.
removeSpareParmFolder(folder)
Removes an empty folder from the spare parameters.
folder
is a sequence of folder names. So, to remove
the Output folder, use ("Output",)
instead of "Output"
.
See also addSpareParmFolder()
, hou.ParmTemplateGroup.remove, and
hou.ParmTemplateGroup.findFolder.
replaceSpareParmTuple(parm_tuple_name, parm_template)
Replace an existing spare parameter tuple with a new one. The old parameter tuple is removed and the new one is added in its place.
parm_tuple_name
The name of the spare parameter tuple to replace. Raises hou.OperationFailed if no parameter tuple exists with this name, or if it is the name of a non-spare parameter.
parm_template
A hou.ParmTemplate describing the new parameter tuple.
The new parameter tuple may or may not have the same name as the old one. By providing a parameter tuple with the same name, you can modify an existing spare parameter tuple.
Note that you cannot replace non-spare parameter tuples. However, you can change the visibility of non-spare parameters using hou.ParmTuple.hide.
To change a parameter for all instances of digital asset, use hou.HDADefinition.replaceParmTuple.
This method is deprecated in favor of setParmTemplateGroup
.
localVariables()
Return a list of local variables that can be referenced in parameter
expressions on this node using the $
prefix.
localAttributes()
Return a list of local variables that can be referenced in parameter
expressions on this node using the @
prefix. This includes local
variables defined in this node as attributes and any context options
that were available to this node the last time it was cooked.
saveParmClip(file_name, start=None, end=None, sample_rate=0, scoped_only=False)
Saves the animation associated with the parameters of this node to the clip file specified by ‹file_name›. The extension of ‹file_name› determines the format of the saved file.
You can use one of the following extensions:
-
.clip
: save animation as plain text (ASCII) clip file. -
.bclip
: save animation as a bclip (binary clip) file. -
.bclip.sc
: save animation as a bclip file using Blosc compression.
Set ‹sample_rate› to a non-zero, non-negative value to specify the sample_rate to be used for the clip file. For example, if the current frame rate is 24 (hou.fps()), and ‹sample_rate› is set to 12, the animation will be sampled every second frame since ‹sample_rate› is half of the current frame rate.
If ‹start› is not None
, start saving the animation from the specified
frame (inclusive).
Otherwise, the animation will be saved from the global start frame (inclusive).
Similarly, if ‹end› is not None
, stop saving the animation at the
specified frame (inclusive).
Otherwise, the animation will be saved until the global end frame (inclusive).
The global start and end frame are specified in the Global Animation Options window.
If ‹scoped_only› is True
, only the animation associated with scoped
parameters will be saved. If there are no scoped parameters,
the animation associated with auto-scoped parameters will be saved.
If ‹scoped_only› is False
, animation associated with any of the
parameters of this node will be saved.
Raises a hou.OperationFailed exception if none of the parameters of this
node have animation. If ‹scoped_only› is True
, this exception can be
raised if none of the scoped parameters have animation, or if none of
the auto-scoped parameters have animation (if the node has no scoped
parameters).
Raises a hou.OperationFailed exception if there is an error saving the animation to file.
Raises a hou.InvalidInput exception if start >= end
. If specifying only
‹start›, ensure that the specified value is less than the global
end frame. Likewise, if specifying only ‹end›, ensure it is larger than
the global start frame.
loadParmClip(file_name, sample_rate=0, start=None)
Load animation for the parameters in this node from the clip file specified by ‹file_name›. See hou.Node.saveParmClip for the list of supported clip file formats.
Any tracks in the clip file that do not match the name of the parameters of this node will be ignored.
If ‹sample_rate› is set to a non-zero, non-negative value, the specified value will be used when loading the animation. For example, if the current frame rate is 24 (hou.fps()) and ‹sample_rate› is set to 12, the animation will be loaded with a keyframe at every second frame since ‹sample_rate› is half of the current frame rate.
‹start› specifies the frame the loaded animation should start from. By default the animation starts at the frame specified in the clip file.
Warning
Any existing keyframes for the parameters of this node that are within the range of the loaded animation will be overwritten with the loaded data.
This function will raise a hou.OperationFailed exception if there is an error reading animation data from the file.
parmClipData(start=None, end=None, binary=True, use_blosc_compression=True, sample_rate=0, scoped_only=False)
→ str
for Python 2, bytes
for Python 3
Returns the clip data for the parameters of this node. This method is similar to hou.Node.saveParmClip, except that it returns the clip data (file contents) instead of saving the animation to a clip file.
‹start›, ‹end›, ‹sample_rate›, and ‹scoped_only› behave the same as in hou.Node.saveParmClip.
If ‹binary› is True
, return binary clip data otherwise return plain
text (ASCII) clip data.
If ‹use_blosc_compression› is True
, blosc compress the binary clip data.
This cannot be used for plain text (ASCII) clip data.
The returned clip data is a bytes
object in Python 3 and a str
object
in Python 2. See HOM binary data for more
information.
Raises a hou.OperationFailed exception if none of the parameters of this tuple have animation.
Raises a hou.InvalidInput exception if start >= end
. If specifying only
‹start›, ensure that the specified value is less than the global
end frame. Likewise, if specifying only ‹end›, ensure it is larger than
the global start frame.
Raises a hou.InvalidInput exception if binary = False
and
use_blosc_compression = True
.
setParmClipData(data, binary=True, blosc_compressed=True, sample_rate=0, start=1)
Load animation for the parameters in this node from the given clip ‹data›. This method is similar to hou.Node.loadParmClip, except that it loads animation from the given clip data instead of a clip file.
The clip data must be a bytes
object in Python 3 and a str
object
in Python 2. See HOM binary data for more
information.
‹sample_rate› and ‹start› behave the same as in hou.Node.loadParmClip.
‹binary› and ‹blosc_compressed› specify the type of input data.
If ‹binary› is True
, the given data is binary clip data
otherwise it is plain text (ASCII) clip data.
If ‹blosc_compressed› is True
, the given data is blosc compressed
binary data. This cannot be used for plain text (ASCII) clip data.
Raises a hou.OperationFailed exception if the given data is invalid.
Raises a hou.InvalidInput exception if binary = False
and
blosc_compressed = True
.
references(include_children = True)
→ tuple
of hou.Node
Return a tuple of nodes that are referenced by this node, either through parameter expressions, referring to the node by name, or using expressions which rely on the data generated by another node. These reflect all the other ways (besides connecting to an input) in which one node may affect another.
Note that the result can differ depending last cook of the nodes. It’s recommended that you first call cook() on the node first.
dependents(include_children = True)
→ tuple
of hou.Node
Return a tuple of nodes that are reference this node, either through parameter expressions, referring to the node by name, or using expressions which rely on the data generated by this node. These reflect all the other ways (besides connecting to an input) in which one node may affect another.
Note that the result can differ depending last cook of the nodes.
fileReferences(recurse = True, project_dir_variable = "HIP", include_all_refs = True)
→ tuple
of hou.Parm and str
tuples
Returns a sequence of tuples representing references to external files (such as textures, geometry files, and asset libraries) from this node. Applies to all sub children of this node if recurse is set to true.
recurse
Recursively apply to the entire operator hierarchy.
project_dir_variable
You can specify the name of an environment variable. If an asset path starts with the variable, it will be replaced with a variable reference in the path string returned by this function.
include_all_refs
If this is True, then the function will return all the file references. If this is False, then the function will return only the selected file references.
See also hou.fileReferences()
createDigitalAsset(name=None, hda_file_name=None, description=None, min_num_inputs=0, max_num_inputs=0, compress_contents=False, comment=None, version=None, save_as_embedded=False, ignore_external_references=False, change_node_type=True, create_backup=True, install_path=None)
→ Node
Create a digital asset from this node. You would typically call this method on subnet nodes.
name
The name of the node type that the new digital asset will define.
hda_file_name
The name of the hda file where Houdini will save the digital asset.
If None
Houdini will use $HOME/houdiniX.Y/hda/OPcustom.hda
.
description
The name that will appear in the tab menu. If None, Houdini will use the name for the description.
min_num_inputs
The minimum number of inputs that need to be wired into instances of the digital asset. See hou.HDADefinition.minNumInputs for more information.
max_num_inputs
The number of input connectors available on instances of the digital asset for input connections. See hou.HDADefinition.minNumInputs for more information.
compress_contents
Whether or not the contents of this digital asset are compressed inside the hda file. See hou.HDAOptions.compressContents for more information.
comment
A user-defined comment string. See hou.HDADefinition.comment for more information.
version
A user-defined version string. See hou.HDADefinition.version for more information.
save_as_embedded
Whether or not the digital asset’s definition will be saved with the
hip file instead of an hda file. When this parameter is True, Houdini
ignores the hda_file_name
parameter. Setting this parameter to True
is equivalent to setting this parameter to False and setting the
hda_file_name
parameter to “Embedded”.
ignore_external_references
If True, Houdini will not generate warnings if the contents of this digital asset reference nodes outside the asset.
change_node_type
Normally, Houdini will change the node creating the digital asset into the new digital asset type. Setting this flag to false will cause the node to remain unchanged.
create_backup
Create a backup before modifying an existing hda file.
install_path
Where to install the new hda. When not specified, it will install to either “Current HIP File” or “Scanned Asset Library Directories”.
createCompiledDigitalAsset(name=None, hda_file_name=None, description=None)
Create a compiled digital asset from this node. You would typically call this method on VOP network nodes, such as Material Shader Builder SHOP, Surface Shader Builder SHOP, or VEX Surface SHOP Type VOPNET. The digital asset does not have contents section, which means it does not have VOP network inside, but instead relies on the saved VEX code sections to provide the shader code.
After the creation of a compiled HDA, if its VEX code section is ever changed manually, the corresponding vex object code section can be recompiled using hou.HDADefinition.compileCodeSection.
name
The name of the node type that the new digital asset will define.
hda_file_name
The name of the hda file where Houdini will save the digital asset.
If None
Houdini will use $HOME/houdiniX.Y/hda/OPcustom.hda
.
description
The name that will appear in the tab menu. If None, Houdini will use the name for the description.
changeNodeType(new_node_type, keep_name=True, keep_parms=True, keep_network_contents=True, force_change_on_node_type_match=False)
→ hou.Node
Changes the node to a new type (within the same context). new_node_type
is the internal string name of the type you want to change to.
Keep_name
, keep_parms
, and keep_network_contents
indicate that the
node should keep the same name, parameter values, and contents,
respectively, after its type has changed. force_change_on_node_type_match
indicates whether to perform the change even when is already of the
specified type.
allowEditingOfContents(propagate=False)
Unlocks a digital asset so its contents can be edited.
To use this function, you must have permission to modify the HDA.
matchCurrentDefinition()
If this node is an unlocked digital asset, change its contents to match what is stored in the definition and lock it. The parameter values are unchanged.
If this node is locked or is not a digital asset, this method has no effect.
See also hou.Node.matchesCurrentDefinition and hou.Node.isLocked.
matchesCurrentDefinition()
→ bool
Return whether the contents of the node are locked to its type definition.
syncDelayedDefinition()
If this node is a digital assets whose contents are currently in a delay-sync condition, the contents will be synced. If it is already synced or not a syncable asset, no effect occurs.
isDelayedDefinition()
→ bool
If this node is a digital assets whose contents are currently in a delay-sync condition, returns true. Otherwise returns false, which will include nodes that are not syncable.
isLockedHDA()
→ bool
If this node is an instance of a digital asset, return whether or not it is locked. Otherwise, return False.
To differentiate between unlocked digital assets and nodes that are not instances of digital assets, check if the node’s type has a definition:
def isUnlockedAsset(node): return not node.isLockedHDA() and node.type().definition() is not None
See hou.HDADefinition.updateFromNode for an example of how to save and lock all unlocked digital asset instances.
isInsideLockedHDA()
→ bool
Return whether this node is inside a locked digital asset. If this node is not inside a locked HDA, the node may deviate from the HDA definition.
isEditableInsideLockedHDA()
→ bool
Return False if the node is contained inside a locked HDA node and, is not marked as editable within that locked HDA, and True otherwise. In particular this function will return True for a node that is not inside a locked HDA (or not inside an HDA at all).
isMaterialManager()
→ bool
Returns True if the node contains materials.
hdaModule()
→ hou.HDAModule
This method is a shortcut for self.type().hdaModule()
to reduce the length
of expressions in Python parameters and button callbacks. See
hou.NodeType.hdaModule for more information.
See also the hm
method and hou.phm().
hm()
→ hou.HDAModule
This method is a shortcut for self.hdaModule()
.
See also hou.phm().
hdaViewerStateModule()
→ hou.HDAViewerStateModule
This method creates an instance of hou.HDAViewerStateModule associated
to the underlying Node
.
See also hou.NodeType.hdaViewerStateModule.
hdaViewerHandleModule()
→ hou.HDAViewerHandleModule
This method creates an instance of hou.HDAViewerHandleModule associated
to the underlying Node
.
See also hou.NodeType.hdaViewerHandleModule.
syncNodeVersionIfNeeded(from_version)
Synchronize the node from the specified version to the current version of its HDA definition. See also hou.HDADefinition.version.
outputForViewFlag()
→ int
Return an integer to indicate which output of the node should be used for display purposes.
Warning
This method can return a negative number if a surface node asset uses an Output node with its index set to -1
. Some nodes use this “trick” to show preview geometry in the viewer, so to be fully robust your code should deal with values less than 0
(unfortunately it’s not clear which output to actually use in the case).
setOutputForViewFlag(output)
Sets which output should be used for display purposes on this node.
creationTime()
→ datetime.datetime
Return the date and time when the node was created.
modificationTime()
→ datetime.datetime
Return the date and time when the node was last modified.
creatorState()
→ str
This returns the name of the viewport tool that was used to be created. This name is not set by default and is usually the empty string.
setCreatorState(state)
This sets the name of the tool that created this node. If you call this
with a name that differs from the node type name, you should also call
setBuiltExplicitly(False)
.
isBuiltExplicitly()
→ bool
Return whether this node was built explicitly (defaults to True). Most nodes are built explicitly, but some are implicitly created by Houdini. For example, if you select geometry from multiple SOPs and then perform an operation, Houdini will put down an implicit merge SOP before performing that operation. When reselecting geometry in SOPs, Houdini will automatically delete any SOPs that were created implicitly.
setBuiltExplicitly(built_explicitly)
Set whether this node was built explicitly (default value is True). If set to False, this node will not show up in various menus and in the Network View pane’s list mode. This flag is typically used for intermediate utility nodes that one is unlikely to want to change its parameters.
isTimeDependent()
→ bool
Return whether the node is time dependent. A time dependent node is re-evaluated every time the frame changes.
lastCookTime()
→ float
Returns the duration of the node’s last cook in milliseconds.
cook(force=False, frame_range=())
Asks or forces the node 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 is 1
.
needsToCook(time=hou.time())
→ bool
Asks if the node needs to re-cook.
cookCount()
→ int
Returns the number of times this node has cooked in the current session.
updateParmStates()
Update the UI states, such as hidden and disabled, for each parameter in the node.
UI states can be expressed as conditionals (i.e. Disable When) which require evaluation. Typically in graphical Houdini the Parameter Pane performs the evaluation when the node is selected in order to determine how the node parameters should look in the pane. However in non-graphical Houdini or if the Parameter Pane has not yet loaded the node, then the evaluation does not occur and the UI states remain at their defaults causing methods such as hou.Parm.isDisabled and hou.Parm.isHidden to return incorrect values. In these cases, it is recommended that hou.Node.updateParmStates is called.
infoTree(verbose=False, debug=False, output_index=0, force_cook=False)
→ hou.NodeInfoTree
Returns a tree structure containing information about the node and its most recently cooked data. The contents of the tree vary widely depending on the node type, and the nature of its cooked data. This tree of data is used to generate the node information window contents.
verbose
Setting verbose
to True
will cause some additional information to
be generated. In particular data that is expensive to calculate, or
which will generate a large amount of information tends to be generated
only if this option is turned on.
debug
Setting debug
to True
will, in a few cases, cause additional
information to be displayed which generally will be most useful when
debugging the internal operation of Houdini. For example, geometry
attributes will display their “data ids”, which can be helpful when
tracking down errors in SOPs written with the HDK.
output_index
Specifies which of the node’s outputs to return information for.
force_cook
If True
, ensures that output has been cooked before building the info tree.
Note that if the node already has errors, this will attempt to recook the node.
cookPathNodes()
→ tuple
of hou.Node
Return a list of the nodes, including nodes in subnets, that were used in the last cook for the network this node belongs to.
canGenerateCookCode(check_parent=False, check_auto_shader=True)
→ bool
Return True if the node can generate compiled cook code and False otherwise.
If check_parent
is true, the parents in the ancestor hierarchy are tested
if any of them can generate code.
If the node cannot generate cook code explicitly, it might still be able
to provide such code implicitly, if it can be wrapped in auto-shader.
E.g., a building-block VOPs such as Anti-Aliased Noise don’t generate
a complete cook code; they provide code fragment that contributes to the
full cook function. But sometimes they can be automatically wrapped in such
a function, which which will act as cook code. If check_auto_shader
is true, the node will be tested if it provides implicit cook code.
cookCodeGeneratorNode(check_parent=False)
→ hou.Node
Return the node itself or a network node that contains this node and can generate compiled cook code. For example, the generator node for a VOP node could be the SHOP node or SOP node that contains it for example.
Return None if this node cannot generate code and is not contained in a code generating node either either.
cookCodeLanguage()
→ str
Return the language of the generated cook code (i.e. VEX, RSL).
Raises hou.OperationFailed if this node cannot generate compiled code.
supportsMultiCookCodeContexts()
→ bool
Return True if this node can generate compiled cook code for multiple contexts (i.e. surface context, displacement context, etc.) and False otherwise.
Raises hou.OperationFailed if this node cannot generate compiled code.
saveCompiledCookCodeToFile(file_name, context_name=None)
Saves compiled VEX code to a disk file (for nodes that support this). See hou.Node.saveCookCodeToFile for a description of the arguments.
saveCookCodeToFile(file_name, skip_header=False, context_name=None)
Saves VEX/RSL source code to a disk file (on nodes that support this).
file_name
The file path in which to save the generated code.
skip_header
If True
, the method does not write a header comment at the beginning
of the file containing the file name and node path from which the code
was generated and a time stamp.
context_name
A string containing name of the shader context for the code. This option applies to nodes such as the Material Shader Builder which can generate code for multiple context types.
For example, a Material network might contain both surface and displacement shaders, so you must specify which type of shader code to generate:
node("/shop/vopmaterial1").saveCookCodeToFile("myfile.vfl", context_name="surface")
On single-context nodes this argument is ignored.
For VEX materials, possible values are surface
, displacement
,
light
, shadow
, fog
, image3d
, photon
, or cvex
.
For RSL materials, possible values are surface
, displacement
,
light
, volume
, or imager
.
addNodeGroup(name=None)
→ hou.NodeGroup
Add a node group to the node and return 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 None or 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 hou.OperationFailed.
To remove a node group, use hou.NodeGroup.destroy.
nodeGroup(name)
→ hou.NodeGroup
Return a node group contained by the node with the given name, or None
if
the group does not exist.
nodeGroups()
→ tuple of hou.NodeGroup
Return the list of node groups in this node.
runInitScripts()
Runs the initialization script associated with this node’s type.
deleteScript()
→ str
Return the script that will run when this node is deleted.
setDeleteScript(script_text, language=hou.scriptLanguage.Python)
Sets the script that will run when this node is deleted.
motionEffectsNetworkPath()
→ str
Return a node path representing the location for storing clips. This location may or may not exist. To find or create such a network, use hou.Node.findOrCreateMotionEffectsNetwork.
findOrCreateMotionEffectsNetwork(create=True)
→ hou.chopNetNodeTypeCategory()
Return a CHOP network node suitable for storing Motion Effects. By default, if the node doesn’t exist, it will be created.
See also hou.Parm.storeAsClip and hou.Node.motionEffectsNetworkPath.
stampValue(parm_name, default_value)
Return a copy stamping floating point or string value. This node must be a downstream stamping operator, such as a Copy SOP, Cache SOP, LSystem SOP, or Copy CHOP.
parm_name
The name of the stamping variable.
default_value
The value that this function returns if Houdini is not currently
performing stamping, or if parm_name
is not a valid variable
name. This value may be a float or a string.
You might put the following expression in a Python parameter:
node("../copy1").stampValue("sides", 5)
saveItemsToFile(items, file_name, save_hda_fallbacks = False)
Given a sequence of child items (nodes, network boxes, sticky notes, etc), save a file containing those items. You can load this file using hou.Node.loadItemsFromFile.
items
A sequence of hou.NetworkMovableItems that are children of this node.
file_name
The name of the file to write the contents to. You can use any extension for this file name.
save_hda_fallbacks
Set to True
to save simplified definitions for HDAs into the file
along with the child nodes. Doing this allows the generated file to
be safely loaded into any houdini session, even if the assets used
in the file are not already loaded into the houdini session. Depending
on the use of the generated file, this information is often not
required and makes the files unnecessarily large.
Raises hou.OperationFailed if any of the nodes or network boxes are node children of this node, or if the file could not be written to. Raises hou.PermissionError if you do not have permission to read the contents of this node.
saveChildrenToFile(nodes, network_boxes, file_name)
Combines separate lists of nods and network boxes into a single sequence,
and calls hou.Node.saveItemsToFile. This method is provided for
backward compatibility. New code should call saveItemsToFile
directly.
nodes
A sequence of hou.Nodes that are children of this node.
network_boxes
A sequence of hou.NetworkBoxes that are contained in this node. Note that the contents of the network boxes are not automatically saved, so it is up to you to put them in the list of nodes.
loadItemsFromFile(file_name, ignore_load_warnings=False)
Load the contents of a file (saved with hou.Node.saveItemsToFile) into the contents of this node.
Raises hou.OperationFailed if the file does not exist or it is not
the correct type of file. Raises hou.PermissionError if this
node is a locked instance of a digital asset. Raises hou.LoadWarning
if the load succeeds but with warnings and ignore_load_warnings
is
False
.
loadChildrenFromFile(file_name, ignore_load_warnings=False)
Calls hou.Node.loadItemsFromFile. Provided for backward
compatibility. New code should call loadItemsFromFile
directly.
asCode(brief=False, recurse=False, save_channels_only=False, save_creation_commands=True, save_keys_in_frames=False, save_outgoing_wires=False, save_parm_values_only=False, save_spare_parms=True, save_box_membership=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 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.
save_box_membership
Output code to add the root item to its parent network box, if any.
function_name
If a function_name is specified, the output will be wrapped in a Python function.
addEventCallback(event_types, callback)
Registers a Python callback that Houdini will call whenever a particular action, or event, occurs on this particular node instance.
Callbacks only persist for the current session. For example, they are not saved to the .hip
file. If you want persistent callbacks in every session, you can add them in code in 456.py
(runs when the user opens a .hip
file). See where to add Python scripting for more information.
event_types
A sequence of hou.nodeEventType enumeration values describing the event types that will cause Houdini to call the callback
function.
callback
A callable Python object, such as a function or bound method. Houdini will call this function whenever one of the event types in event_types
occurs.
Houdini calls the function with an event_type
keyword argument containing the hou.nodeEventType value corresponding to the event that triggered the callback.
Houdini will pass additional keyword arguments depending on the event type. For example, in a callback for the ParmTupleChanged
event, Houdini will pass a parm_tuple
keyword argument containing a hou.ParmTuple reference to the parameter that changed. See hou.nodeEventType for the extra arguments (if any) passed for each event type.
You can add **kwargs
to the argument list to accept all keyword arguments, to allow the same callback to be used for different events, or to be safe from future changes:
def event_callback(event_type, **kwargs): ...
Note
If you try to add the exact same callback function more than once, Houdini will still only call the function only once in response to an event. However, it may be useful to “add” the same function if you want to register it with different event_types
.
Raises hou.OperationFailed if the event_types
list argument is
empty.
The following example shows to set up a function that’s called whenever a certain node’s name changes:
def name_changed(node, event_type, **kwargs): print("The geometry object is now named", node.name()) hou.node("/obj/geo1").addEventCallback((hou.nodeEventType.NameChanged, ), name_changed)
See also hou.Node.removeEventCallback and hou.Node.removeAllEventCallbacks.
removeEventCallback(event_types, callback)
Given a callback that was previously added on this node and a sequence of hou.nodeEventType enumerated values, remove those event types from the set of event types for the callback. If the remaining set of event types is empty, the callback will be removed entirely from this node.
Raises hou.OperationFailed if the callback had not been previously added.
See hou.Node.addEventCallback for more information.
addParmCallback(callback, parm_names)
Registers a Python callback that Houdini will call whenever a parameter in
parm_names
changes on this particular node instance. This is can be faster
than filtering the parameter names in a callback installed with
hou.Node.addEventCallback if you only care about some parameters or if
the node has many parameters.
callback
A callable Python object, such as a function or bound method. Houdini will call this function whenever one of the event types in event_types
occurs.
parm_names
All list of parameter names.
See hou.Node.addEventCallback for more information.
removeAllEventCallbacks()
Remove all event callbacks for all event types from this node.
See hou.Node.addEventCallback for more information.
Warning
removeAllEventCallbacks
should be used carefully, especially
with viewer states as it may cause functionality to silently
stop working when entering a state.
eventCallbacks()
→ tuple
of (tuple
of hou.nodeEventType, callback)
Return a tuple of all the Python callbacks that have been registered with this node with calls to hou.Node.addEventCallback.
setCachedUserData(name, value)
Add/set a named value on this node instance. Unlike setUserData
,
values set using this method are not saved with the hip file.
name
:
A unique name (key) for the user-defined data. By using different
names, you can attach multiple pieces of user-defined data to a node.
value
:
The value to store. Unlike setUserData
, this value may be any Python
object.
This name/value pair is not stored with the hip file. It is useful for nodes implemented in Python that want to save temporary values between cooks, to avoid recomputing them on subsequent cooks.
The following example illustrates how to set, access, and delete cached user-defined data:
>>> n = hou.node("/obj").createNode("geo") >>> n.setCachedUserData("my data", [1, 2, {"a": "b", "c": "d"}]) >>> n.cachedUserData("my data") [1, 2, {'a': 'b', 'c': 'd'}] >>> n.cachedUserDataDict() {'my data': [1, 2, {'a': 'b', 'c': 'd'}]} >>> n.destroyCachedUserData("my data") >>> n.cachedUserDataDict() {} >>> print n.cachedUserData("my data") None
See per-node user-defined data for more information and examples.
cachedUserDataDict()
→ dict
of str
to any python object`
Return a dictionary containing all the user-defined name/string pairs for this node.
See hou.Node.setCachedUserData for more information.
cachedUserData(name)
→ any python obect or None
Return the user-defined cached data with this name, or None
if no data
with this name exists.
See hou.Node.setCachedUserData for more information.
This method can be implemented as follows:
def cachedUserData(self, name): return self.cachedUserDataDict().get(name)
Note that None
is a valid value for a key, so the most reliable way to
check if a key is valid is to check if it is in the result of
cachedUserDataDict
:
>>> n = hou.node("/obj").createNode("geo") >>> n.cachedUserDataDict() {} >>> print n.cachedUserData("foo") None >>> "foo" in n.cachedUserDataDict() False >>> n.setCachedUserData("foo", None) >>> n.cachedUserDataDict() {'foo': None} >>> print n.cachedUserData("foo") None >>> "foo" in n.cachedUserDataDict() True
destroyCachedUserData(name, must_exist=True)
Remove the user-defined cached data with this name.
See hou.Node.setCachedUserData for more information.
Raises hou.OperationFailed if no user data with this name exists and must_exist is True.
clearCachedUserDataDict()
Remove all user-defined cached data.
See hou.Node.setCachedUserData for more information.
dataBlockKeys(blocktype)
→ tuple
of str
Return the names of all data blocks stored on this node that are of the
data type specified by the blocktype
parameter.
Data blocks are similar to user data in that they can contain any extra data that may be useful to attach to a specific node. They differ from user data in that data blocks are designed to more efficiently handle large blocks of data. Data blocks can also contain binary data, and have a data type associated with each block.
dataBlockType(key)
→ str
Return the data type of the block specified by the key
parameter.
Raises hou.ValueError if the provided key is not associated with any data block on this node.
dataBlock(key)
→ str
for Python 2, bytes
for Python 3
Returns the data block as a binary string stored under the given key. This method will only work if the specified data block is has a type that can be represented by a python object. Otherwise None is returned.
The returned binary string is a bytes
object in Python 3 and a str
object in Python 2. See HOM binary data for more
information.
Raises hou.ValueError if the provided key is not associated with any data block on this node.
setDataBlock(key, block, block_type=None)
Stores the provided data block on the node under the provided key name, marking it with the provided data type.
Passing an empty string as the block value will remove any data block with
the specified key. Data blocks can also be removed with the
removeDataBlock()
method.
The blocktype string argument requires a C++/HDK plugin to interpret data blocks and turn them into C++ objects. If you're using Python to get and set data blocks, leave the blocktype empty.
removeDataBlock(key)
Removes any existing data block on the node with the specified key. If there is no data block with this key, this method does nothing.
simulation()
→ hou.DopSimulation
Return the simulation defined by this DOP network node. This raises an exception if this is not a dop network.
findNodesThatProcessedObject(dop_object)
→ tuple
of hou.DopNode
Given a hou.DopObject, return a tuple of DOP nodes that processed that object. This raises an exception if this is not a dopnetwork.
selectNextVisibleWorkItem()
If a work item is selected, selects the next visible work item
selectPreviousVisibleWorkItem()
If a work item is selected, selects the previous work item
deselectWorkItem()
Deselects the active work item if this node is inside or contains the TOP network with the currently selected work item.
setCurrentTOPPage(page_index)
If a TOP node can’t display all work items, sets which work item subset (page) will be displayed
addMessage(message)
Add an info message badge to the node
message
A string containing the info message to show on the node.
Note
This should only be called on the currently cooking node within a cook.
addWarning(message)
Add a warning badge to the node
message
A string containing the warning message to show on the node.
Note
This should only be called on the currently cooking node within a cook.
addError(message, severity=Hom:hou.severityType.Error)
Add an error badge to the node
message
A string containing the error message to show on the node.
severity
A hou.severityType object that specifies the severity level
Note
This should only be called on the currently cooking node within a cook.
inputsWithIndices(ignore_network_dots=False, ignore_subnet_indirect_inputs=False, use_names=False) -> Sequence[hou.OpNode, int | str, int | str]]
Returns a sequence of tuples representing each connected input of this node, where each tuple has three items:
-
A
hou.OpNode
instance representing the node connected to this input. -
An int representing the index (or a string representing the internal name, depending on the
use_names
argument) of the upstream node’s output that is connected to this input. -
An int representing the index (or a string representing the internal name, depending on the
use_names
argument) of this input.
ignore_network_dots
Ignore any network dots connected to each input and return the nearest upstream node instead.
ignore_subnet_indirect_inputs
If an input is connected to a subnet input, return the node connected to the subnet in the parent network instead of the subnet input pseudo-node.
use_names
Return the internal names of the connections instead of their indices.
outputsWithIndices(ignore_network_dots=False, use_names=False) -> Sequence[hou.OpNode, int | str, int | str]]
Returns a sequence of tuples representing each connected output of this node, where each tuple has three items:
-
A
hou.OpNode
instance representing the node connected to this output. -
An int representing the index (or a string representing the internal name, depending on the
use_names
argument) of the output. -
An int representing the index (or a string representing the internal name, depending on the
use_names
argument) of the downstream node’s input that is connected to this input.
ignore_network_dots
Ignore any network dots connected to each input and return the nearest upstream node instead.
use_names
Return the internal names of the connections instead of their indices.
asData(nodes_only=False, children=False, editables=False, inputs=False, outputs=False, position=False, flags=False, parms: Union[bool, Sequence[hou.ParmTuple], Sequence[str]] = True, sparparms=True, parms_as_brief=True, default_parmvalues=False, evaluate_parmvalues=False, parmtemplates="spare_only", metadata=False, callback: Callable = None) -> dict[str, Any]
Returns a JSON-like data structure representing this node.
setFromData(data: dict[str, Any], clear_content=False, force_item_creation=True, parms=True, parmtemplates=True, children=True, editables=True, skip_notes=False) -> None
Updates the parameters, options, and contents of this node from data
, as returned by OpNode.asData()
.
parmsAsData(values=True, parms=True, default_values=False, evaluate_values=False, locked=True, brief=True, multiparm_instances=True, metadata=False, callback: Callable = None) -> dict[str, Any]
Returns a JSON-like data strcture representing this node’s parameters.
setParmsFromData(data: dict[str, Any]) -> None
Updates the parameters on this node from data
, as returned by OpNode.parmsAsData()
.
childrenAsData(nodes_only=False, children=True, editables=True, inputs=True, outputs=False, position=True, flags=True, parms=True, spareparms=True, parms_as_brief=True, default_parmvalues=False, evaluate_parmvalues=False, parmtemplates="spare_only", metadata=False, callback: Callable = None) -> dict[str, Any]
Returns a JSON-like data strcture representing the contents of this node.
setChildrenFromData(clear_content=True, external_connections=True, start_position: hou.Vector2 = None, force_item_creation=True, parms=True,parmtemplates=True, children=True editables=True, skip_notes=False) -> None
Replaces or updates the content of this node using data
, as returned by OpNode.childrenAsData()
.
editablesAsData(nodes_only=False, children=True, editables=True, inputs=True, outputs=False, position=True, flags=True, parms=True, spareparms=True, parms_as_brief=True, default_parmvalues=False, evaluate_parmvalues=False, parmtemplates="spare_only", metadata=False, callback: Callable = None) -> dict[str, Any]
Returns a JSON-like data structure representing the contents of any editable dive targets inside this node.
setEditablesFromData(clear_content=True, external_connections=True, start_position: hou.Vector2 = None, force_item_creation=True, parms=True,parmtemplates=True, children=True editables=True, skip_notes=False) -> None
Replaces or updates the content of any editable dive targets inside this node using data
, as returned by OpNode.childrenAsData()
.
createDecorationItemsFromData(data: dict[str, Any]) -> None
Create the network items represented by data
as “decorations” with this node as the target. See decoration recipes for more information.
parmTemplatesAsData(name: str = "", children=True, callback: Callable = None) -> dict[str, Any]
Returns a JSON-like data structure representing the parameter template group of this node.
appendParmTemplatesFromData(data: dict[str, Any], rename_conflicts=True) -> None
Creates spare parameters from the data
(as returned by OpNode.parmTemplatesAsData()
), and adds them to this node’s parameter template group, after existing parameters.
replaceParmTemplatesFromData(data: dict[str, Any]) -> None
Creates spare parameters from the data
(as returned by OpNode.parmTemplatesAsData()
), and replaces any existing parameters with the same names on this node.
insertParmTemplatesBeforeFromData(data: dict[str, Any], parm_name: str, rename_conflicts=True) -> None
Creates spare parameters from the data
(as returned by OpNode.parmTemplatesAsData()
), and inserts them before the parameter named ‹parm_name›.
insertParmTemplatesAfterFromData(data: dict[str, Any], parm_name: str, rename_conflicts=True)
Creates spare parameters from the data
(as returned by OpNode.parmTemplatesAsData()
), and inserts them after the parameter named ‹parm_name›.
appendParmTemplatesToFolderFromData(data: dict[str, Any], parm_name: str, rename_conflicts=True) -> None
Creates spare parameters from the data
(as returned by OpNode.parmTemplatesAsData()
), and inserts at the start of the folder named ‹parm_name›.
prependParmTemplatesToFolderFromData(data: dict[str, Any], parm_name: str, rename_conflicts=True) -> None
Creates spare parameters from the data
(as returned by OpNode.parmTemplatesAsData()
), and inserts at the start of the folder named ‹parm_name›.
inputsAsData(ignore_network_dots=False, ignore_subnet_indirect_inputs=False, use_names=False) -> Sequence[dict[str, Any]]
Returns a JSON-like data structure representing this node’s input connections.
setInputsFromData(data: dict[str, Any]) -> None
Creates input wires on this node from data
, as returned by OpNode.inputsAsData()
.
outputsAsData(ignore_network_dots=False, ignore_subnet_indirect_inputs=False, use_names=False) -> Sequence[dict[str, Any]]
Returns a JSON-like data structure representing this node’s output connections.
setOutputsFromData() -> None
Creates output wires on this node from data
, as returned by OpNode.inputsAsData()
.