houdini_core_tools package

Subpackages

Submodules

houdini_core_tools.bounding module

Function related to bounding items.

houdini_core_tools.bounding.add_to_bounding_box_max(bbox: hou.BoundingBox, vec: hou.Vector3) None[source]

Add values to the maximum bounds of this bounding box.

Parameters:
  • bbox – The bounding box to expand.

  • vec – The values to add.

houdini_core_tools.bounding.add_to_bounding_box_min(bbox: hou.BoundingBox, vec: hou.Vector3) None[source]

Add values to the minimum bounds of this bounding box.

Parameters:
  • bbox – The bounding box to expand.

  • vec – The values to add.

houdini_core_tools.bounding.bounding_box_area(bbox: hou.BoundingBox) float[source]

Calculate the area of this bounding box.

Parameters:

bbox – The bounding box to get the area of.

Returns:

The area of the box.

houdini_core_tools.bounding.bounding_box_is_inside(source_bbox: hou.BoundingBox, target_bbox: hou.BoundingBox) bool[source]

Determine if this bounding box is totally enclosed by another box.

Parameters:
  • source_bbox – The bounding box to check for being enclosed.

  • target_bbox – The bounding box to check for enclosure.

Returns:

Whether this object is totally enclosed by the other box.

houdini_core_tools.bounding.bounding_box_volume(bbox: hou.BoundingBox) float[source]

Calculate the volume of this bounding box.

Parameters:

bbox – The bounding box to get the volume of.

Returns:

The volume of the box.

houdini_core_tools.bounding.bounding_boxes_intersect(bbox1: hou.BoundingBox, bbox2: hou.BoundingBox) bool[source]

Determine if the bounding boxes intersect.

Parameters:
  • bbox1 – A bounding box to check for intersection with.

  • bbox2 – A bounding box to check for intersection with.

Returns:

Whether this object intersects the other box.

houdini_core_tools.bounding.compute_bounding_box_intersection(bbox1: hou.BoundingBox, bbox2: hou.BoundingBox) hou.BoundingBox | None[source]

Compute the intersection of two bounding boxes.

Parameters:
  • bbox1 – A box to compute intersection with.

  • bbox2 – A box to compute intersection with.

Returns:

The intersection of the bounding boxes, otherwise None if they do not intersect.

houdini_core_tools.bounding.expand_bounding_box(bbox: hou.BoundingBox, delta_x: float, delta_y: float, delta_z: float) None[source]

Expand the min and max bounds in each direction by the axis delta.

Parameters:
  • bbox – The bounding box to expand.

  • delta_x – The X value to expand by.

  • delta_y – The Y value to expand by.

  • delta_z – The Z value to expand by.

houdini_core_tools.context_managers module

Houdini related context managers.

class houdini_core_tools.context_managers.emit_varchange[source]

Bases: ContextDecorator

Emit a varchange call at the end of the scope.

In the event of nested uses, only the outermost will execute the varchange.

>>> with emit_varchange():
...     hou.hscript("set FOO=456")
...
>>> # A varchange call will have been emitted for FOO.
class houdini_core_tools.context_managers.temporarily_unlock_parameters(parms_to_unlock: hou.Parm | hou.ParmTuple | Iterable[hou.Parm])[source]

Bases: ContextDecorator

Context manager to temporarily unlock parameters and re-lock them on exit.

>>> my_parameter = hou.parm("/obj/geo1/scale")
>>> with temporarily_unlock_parameters(my_parameter):
...     my_parameter.set(3)
...
Parameters:

parms_to_unlock – The parameter(s) to unlock.

houdini_core_tools.context_managers.context_container(category: hou.NodeTypeCategory, *, destroy: bool = True) Generator[hou.OpNode, None, None][source]

Context manager that provides an appropriate node to create a node under.

If the container type needs to be created it will be, then it will be destroyed after the scope of the manager if destroy is True.

>>> with context_container(hou.sopNodeTypeCategory()) as container:
...     container.createNode("box")
Parameters:
  • category – The node type category of the node to create.

  • destroy – Whether to destroy the node or not.

Returns:

An appropriate parent node to create a node of the desired type under.

Raises:

UnsupportedCategoryError – Raised if the category does not correspond to a known/supported type.

houdini_core_tools.context_managers.restore_current_selection() Generator[None, None, None][source]

Restore the current selection after the block has exited.

The selection will be restored in the event an exception occurs inside the block.

>>> with restore_current_selection():
...     # Perform actions that could change the selection.
...
houdini_core_tools.context_managers.set_current_node(node: hou.Node) Generator[None, None, None][source]

Temporarily set the current for the scope of the block.

The current node is that returned by hou.pwd().

The current mode will be restored in the event an exception occurs inside the block.

>>> with set_current_node(hou.node("/obj")):
...     # Perform actions where hou.pwd() is used.
...
Parameters:

node – The temporary node.

houdini_core_tools.context_managers.set_temporary_update_mode(update_mode: hou.updateMode) Generator[None, None, None][source]

Temporarily set the UI update mode for the scope of the block.

The update mode will be restored in the event an exception occurs inside the block.

>>> with set_temporary_update_mode(hou.updateMode.Manual):
...     # Perform actions while in manual mode.
...
Parameters:

update_mode – The temporary update mode.

houdini_core_tools.exceptions module

Custom exceptions for houdini_core_tools.

exception houdini_core_tools.exceptions.AttributeNotAStringError(attribute: hou.Attrib)[source]

Bases: ValueError

Exception for when an attribute is not a string.

exception houdini_core_tools.exceptions.InvalidAttributeTypeError(attribute_type: hou.attribType, expected: Sequence[hou.attribType])[source]

Bases: ValueError

Exception for when an attribute is not the expected type.

exception houdini_core_tools.exceptions.InvalidGroupTypeError(group_type: type[hou.PointGroup | hou.PrimGroup | hou.VertexGroup], expected_type: type[hou.PointGroup | hou.PrimGroup | hou.VertexGroup])[source]

Bases: ValueError

Exception for when a group is not the expected type.

exception houdini_core_tools.exceptions.InvalidMultiParmIndicesError(parameter_name: str)[source]

Bases: ValueError

Exception for when multiparm indices do not map to an existing parameter.

exception houdini_core_tools.exceptions.MissingMultiParmTokenError(parameter_name: str)[source]

Bases: ValueError

Exception for when a parameter name does not contain at least one multiparm token.

exception houdini_core_tools.exceptions.NotEnoughMultiParmIndicesError(name: str, token_count: int, num_indices: int)[source]

Bases: ValueError

Exception for when not enough indices are provided while evaluating multiparm tokens.

exception houdini_core_tools.exceptions.NoMatchingParameterTemplate(name: str, node: hou.OpNode)[source]

Bases: ValueError

Exception for when a node does not have a parameter template of the name.

exception houdini_core_tools.exceptions.ParameterIsNotAMultiParmInstanceError(parameter_name: str)[source]

Bases: ValueError

Exception for when a parameter is not a multiparm instance.

exception houdini_core_tools.exceptions.ParameterIsNotAStringError(parameter_template: hou.ParmTemplate)[source]

Bases: ValueError

Exception for when a parameter is not a multiparm instance.

exception houdini_core_tools.exceptions.ParameterNotAButtonStripError(parameter: hou.Parm)[source]

Bases: ValueError

Exception for when a parameter is not a button strip.

exception houdini_core_tools.exceptions.ParameterTemplateIsNotAMultiParmError[source]

Bases: ValueError

Exception for when a parameter template is not a multiparm folder.

exception houdini_core_tools.exceptions.ParmTupleTypeError(parm_tuple: hou.ParmTuple, expected_type: str)[source]

Bases: ValueError

Exception raised when a parameter tuple is not of a certain special type.

exception houdini_core_tools.exceptions.PrimitiveIsRawGeometryError(point: hou.Point)[source]

Bases: ValueError

Exception for when a point is bound to a primitive that is raw geometry.

exception houdini_core_tools.exceptions.UnexpectedAttributeTypeError(value: Any)[source]

Bases: ValueError

Exception for passing an invalid hou.attribType value.

exception houdini_core_tools.exceptions.UnexpectedGroupTypeError(value: type[Any])[source]

Bases: ValueError

Exception for passing an invalid group type value.

exception houdini_core_tools.exceptions.UnsupportedCategoryError(category: hou.NodeTypeCategory)[source]

Bases: ValueError

Exception raised when an invalid node type category is passed.

Parameters:

category – The invalid node type category.

exception houdini_core_tools.exceptions.VectorIsZeroVectorError[source]

Bases: ValueError

Exception for a zero vector being passed.

houdini_core_tools.geometry module

Functions related to Houdini geometry.

houdini_core_tools.geometry.check_minimum_polygon_vertex_count(geometry: hou.Geometry, minimum_vertices: int, *, ignore_open: bool = True) bool[source]

Check that all polygons have a minimum number of vertices.

This will ignore non-polygon types such as packed and volume primitives.

Parameters:
  • geometry – The geometry to check.

  • minimum_vertices – The minimum number of vertices a polygon must have.

  • ignore_open – Ignore polygons which are open.

Returns:

Whether all the polygons have the minimum number of vertices.

houdini_core_tools.geometry.connected_points(point: hou.Point) tuple[hou.Point, ...][source]

Get all points that share an edge with the point.

Parameters:

point – The source point.

Returns:

Connected points

houdini_core_tools.geometry.face_has_edge(face: hou.Face, point1: hou.Point, point2: hou.Point) bool[source]

Test if the face has an edge between two points.

Parameters:
  • face – The face to check for an edge.

  • point1 – A point to test for an edge with.

  • point2 – A point to test for an edge with.

Returns:

Whether the points share an edge.

houdini_core_tools.geometry.find_attrib(geometry: hou.Geometry, attrib_type: hou.attribType, name: str) hou.Attrib | None[source]

Find an attribute with a given name and type on the geometry.

Parameters:
  • geometry – The geometry to find an attribute on.

  • attrib_type – The attribute type.

  • name – The attribute name.

Returns:

A found attribute, otherwise None.

Raises:

UnexpectedAttributeTypeError – When an invalid attrib_type is passed.

houdini_core_tools.geometry.find_group(geometry: hou.Geometry, group_type: type[hou.EdgeGroup | hou.PointGroup | hou.PrimGroup | hou.VertexGroup], name: str) hou.EdgeGroup | hou.PointGroup | hou.PrimGroup | hou.VertexGroup | None[source]

Find a group with a given name and type on the geometry.

Parameters:
  • geometry – The geometry to find a group on.

  • group_type – The group type.

  • name – The group name.

Returns:

A found group, otherwise None.

Raises:

UnexpectedGroupTypeError – When an invalid group type is passed.

houdini_core_tools.geometry.geo_details_match(geometry1: hou.Geometry, geometry2: hou.Geometry) bool[source]

Test if two hou.Geometry objects point to the same detail.

Parameters:
  • geometry1 – A geometry detail.

  • geometry2 – A geometry detail.

Returns:

Whether the objects represent the same detail.

houdini_core_tools.geometry.geometry_has_prims_with_shared_vertex_points(geometry: hou.Geometry) bool[source]

Check if the geometry contains any primitives which have more than one vertex referencing the same point.

Parameters:

geometry – The geometry to check.

Returns:

Whether the geometry has any primitives with shared vertex points.

houdini_core_tools.geometry.get_oriented_point_transform(point: hou.Point) hou.Matrix4[source]

Get a transform matrix from a point.

This matrix may be the result of standard point instance attributes or if the point has any non-raw geometry primitives bound to it (PackedPrim, Quadric, VDB, Volume) then the transform from the first primitive will be returned.

Parameters:

point – The point.

Returns:

A matrix representing the point transform.

Raises:

hou.OperationFailed – If the connected prim is a face or surface.

houdini_core_tools.geometry.get_points_from_list(geometry: hou.Geometry, point_list: Sequence[int]) tuple[hou.Point, ...][source]

Convert a list of point numbers to hou.Point objects.

Parameters:
  • geometry – The geometry to get points for.

  • point_list – A list of point numbers.

Returns:

Matching points on the geometry.

houdini_core_tools.geometry.get_prims_from_list(geometry: hou.Geometry, prim_list: Sequence[int]) tuple[hou.Prim, ...][source]

Convert a list of primitive numbers to hou.Prim objects.

Parameters:
  • geometry – The geometry to get prims for.

  • prim_list – A list of prim numbers.

Returns:

Matching prims on the geometry.

houdini_core_tools.geometry.get_primitives_with_shared_vertex_points(geometry: hou.Geometry) tuple[hou.Prim, ...][source]

Get any primitives in the geometry which have more than one vertex referencing the same point.

Parameters:

geometry – The geometry to check.

Returns:

A list of any primitives which have shared vertex points.

houdini_core_tools.geometry.group_bounding_box(group: hou.EdgeGroup | hou.PointGroup | hou.PrimGroup) hou.BoundingBox[source]

Get the bounding box of the group.

Parameters:

group – The group to get the bounding box for.

Returns:

The bounding box for the group.

Raises:

TypeError – If the object is not a supported group type.

houdini_core_tools.geometry.num_points(geometry: hou.Geometry) int[source]

Get the number of points in the geometry.

This should be quicker than len(hou.Geometry.iterPoints()) since it uses the ‘pointcount’ intrinsic value from the detail.

Parameters:

geometry – The geometry to get the point count for.

Return type:

The point count

houdini_core_tools.geometry.num_prims(geometry: hou.Geometry) int[source]

Get the number of primitives in the geometry.

This should be quicker than len(hou.Geometry.iterPrims()) since it uses the ‘primitivecount’ intrinsic value from the detail.

Parameters:

geometry – The geometry to get the primitive count for.

Return type:

The primitive count

houdini_core_tools.geometry.num_vertices(geometry: hou.Geometry) int[source]

Get the number of vertices in the geometry.

Parameters:

geometry – The geometry to get the vertex count for.

Returns:

The vertex count.

houdini_core_tools.geometry.point_instance_transform(point: hou.Point) hou.Matrix4[source]

Get a point’s instance transform based on existing attributes.

Parameters:

point – The point.

Returns:

A matrix representing the instance transform.

houdini_core_tools.geometry.primitive_area(prim: hou.Prim) float[source]

Get the area of the primitive.

This method just wraps the “measuredarea” intrinsic value.

Parameters:

prim – The primitive to get the area of.

Returns:

The primitive area.

houdini_core_tools.geometry.primitive_bary_center(prim: hou.Prim) hou.Vector3[source]

Get the barycenter of the primitive.

Parameters:

prim – The primitive to get the center of.

Returns:

The barycenter.

houdini_core_tools.geometry.primitive_bounding_box(prim: hou.Prim) hou.BoundingBox[source]

Get the bounding box of the primitive.

This method just wraps the “bounds” intrinsic value.

Parameters:

prim – The primitive to get the bounding box of.

Returns:

The primitive bounding box.

houdini_core_tools.geometry.primitive_perimeter(prim: hou.Prim) float[source]

Get the perimeter of the primitive.

This method just wraps the “measuredperimeter” intrinsic value.

Parameters:

prim – The primitive to get the perimeter of.

Returns:

The primitive perimeter.

houdini_core_tools.geometry.primitive_volume(prim: hou.Prim) float[source]

Get the volume of the primitive.

This method just wraps the “measuredvolume” intrinsic value.

Parameters:

prim – The primitive to get the volume of.

Returns:

The primitive volume.

houdini_core_tools.geometry.reverse_prim(prim: hou.Prim) None[source]

Reverse the vertex order of the primitive.

Parameters:

prim – The primitive to reverse.

Raises:

GeometryPermissionError – If the target geometry is read only.

houdini_core_tools.geometry.set_shared_string_attrib(attribute: hou.Attrib, value: str, *, group: hou.PointGroup | hou.PrimGroup | hou.VertexGroup | None = None) None[source]

Set a string attribute value for elements.

If group is None, all elements will receive the value. If a group is passed, only the elements in the group will be set.

Parameters:
  • attribute – The attribute to set.

  • value – The value to set.

  • group – An optional group.

Raises:

AttributeNotAStringError – If the attribute is not a string.

houdini_core_tools.geometry.shared_edges(face1: hou.Face, face2: hou.Face) tuple[hou.Edge, ...][source]

Get a tuple of any shared edges between two primitives.

Parameters:
  • face1 – The face to check for shared edges.

  • face2 – The other face to check for shared edges.

Returns:

A tuple of shared edges.

houdini_core_tools.hdas module

Functions related to Houdini digital assets.

houdini_core_tools.hdas.get_embedded_asset_definitions() tuple[hou.HDADefinition, ...][source]

Get any digital assets embedded in the hip file.

Returns:

Any digital assets embedded in the current hip file.

houdini_core_tools.hdas.get_in_use_hda_definitions(*, include_hfs: bool = False) tuple[hou.HDADefinition, ...][source]

Get any digital asset definitions in use in the current session.

Parameters:

include_hfs – Whether to include definitions loaded from the Houdini install directory.

Returns:

All in use HDA definitions.

houdini_core_tools.hdas.get_in_use_hda_files(*, include_hfs: bool = False) tuple[Path, ...][source]

Get all digital asset source files with definitions in use in the session.

Parameters:

include_hfs – Whether to include definitions loaded from the Houdini install directory.

Returns:

All in use HDA files.

houdini_core_tools.hdas.get_node_descriptive_parameter(node: hou.OpNode) hou.Parm | None[source]

Get a node’s descriptive parameter, if any.

Parameters:

node – The node to get the descriptive parameter for.

Returns:

The node’s descriptive parameter, if any.

houdini_core_tools.hdas.get_node_dive_target(node: hou.OpNode) hou.OpNode | None[source]

Get this node’s dive target node.

Parameters:

node – The node to get the dive target of.

Returns:

The node’s dive target.

houdini_core_tools.hdas.get_node_editable_nodes(node: hou.OpNode) tuple[hou.OpNode, ...][source]

Get a list of the node’s editable nodes.

Parameters:

node – The node to get the editable nodes for.

Returns:

A tuple of editable nodes.

houdini_core_tools.hdas.get_node_guide_geometry_node(node: hou.OpNode) hou.OpNode | None[source]

Get a node’s guide geometry node.

Parameters:

node – The node to get the guide geometry node for.

Returns:

The guide geometry node, if any.

houdini_core_tools.hdas.get_node_message_nodes(node: hou.OpNode) tuple[hou.OpNode, ...][source]

Get a list of the node’s message nodes.

Parameters:

node – The node to get the message nodes for.

Returns:

A tuple of message nodes.

houdini_core_tools.hdas.get_node_representative_node(node: hou.OpNode) hou.OpNode | None[source]

Get the representative node of this node, if any.

Parameters:

node – The node to get the representative node for.

Returns:

The node’s representative node.

houdini_core_tools.hdas.is_digital_asset(node_or_node_type: hou.Node | hou.NodeType) bool[source]

Test whether a node or type is a digital asset.

A node(type) is a digital asset if it has a hou.HDADefinition.

Parameters:

node_or_node_type – A node or node type to test for being a digital asset.

Returns:

Whether the node or node type is a digital asset.

houdini_core_tools.hip_file module

Functions related to hip files.

houdini_core_tools.hip_file.check_unsaved_changes(*, prompt: bool = False) Callable[source]

Function decorator ensures there are no unsaved changes in the session.

Parameters:

prompt – Whether to prompt the user to save the hip file.

Returns:

The wrapped function.

houdini_core_tools.hip_file.get_hip_save_time_from_file(hip_path: Path | str) datetime | None[source]

Get the time the hip file was last saved.

This function uses the value of $_HIP_SAVETIME stored in the file.

Returns:

The time the hip file was last saved, if any.

houdini_core_tools.hip_file.get_hip_save_version_from_file(hip_path: Path | str) tuple[int, ...] | None[source]

Get the version of Houdini last used to save the hip file.

This function uses the value of $_HIP_SAVEVERSION stored in the file.

Returns:

The Houdini version last used to save the hip file, if any.

houdini_core_tools.hip_file.hip_save_time() datetime | None[source]

Get the time the current hip file was last saved.

This function uses the value of $_HIP_SAVETIME.

Returns:

The time the hip file was last saved, if any.

houdini_core_tools.hip_file.hip_save_version() tuple[int, ...] | None[source]

Get the version of Houdini last used to save the current hip file.

This function uses the value of $_HIP_SAVEVERSION.

Returns:

The Houdini version last used to save the hip file, if any.

houdini_core_tools.hip_file.hip_version() str | None[source]

Get the major version of the current hip file.

Returns None if the version could not be determined.

Returns:

The hip file version, if any.

houdini_core_tools.hip_file.save_copy(file_path: str | Path) None[source]

Save a copy of the current session without saving to the current hip file.

Parameters:

file_path – The target file path.

houdini_core_tools.hip_file.set_frame_range(start: float, end: float) None[source]

Set the current frame range.

If the current frame is not within the new range it will be updated to the start frame.

Parameters:
  • start – The start frame.

  • end – The end frame.

houdini_core_tools.math module

Functions related to math in Houdini.

houdini_core_tools.math.build_instance_matrix(position: hou.Vector3, direction: hou.Vector3 | None = None, pscale: float = 1.0, scale: hou.Vector3 | None = None, up_vector: hou.Vector3 | None = None, rot: hou.Quaternion | None = None, trans: hou.Vector3 | None = None, pivot: hou.Vector3 | None = None, orient: hou.Quaternion | None = None) hou.Matrix4[source]

Compute a transform to orient to a given direction.

The transform can be computed for an optional position and scale.

The up vector is optional and will orient the matrix to this up vector. If no up vector is given, the Z axis will be oriented to point in the supplied direction.

If a rotation quaternion is specified, the orientation will be additionally transformed by the rotation.

If a translation is specified, the entire frame of reference will be moved by this translation (unaffected by the scale or rotation).

If a pivot is specified, use it as the local transformation of the instance.

If orient is specified, the orientation (using the direction and up vector) will not be performed and this orientation will instead be used to define an original orientation.

See https://www.sidefx.com/docs/houdini//copy/instanceattrs.html for more details.

Parameters:
  • position – The position of the object to transform.

  • direction – “Velocity” vector. Uses (0, 0, 1) if not defined.

  • pscale – Uniform scaling.

  • scale – Optional non-uniform scale. Uses (1, 0, 1) if not defined.

  • up_vector – Optional up vector when not using orient. Uses (0, 1, 0) if not defined.

  • rot – Optional additional rotation. Uses (0, 0, 0, 1) if not defined.

  • trans – Optional additional translation. Uses (0, 0, 0) if not defined.

  • pivot – Optional local pivot point. Uses (0, 0, 0) if not defined.

  • orient – Optional orientation quaternion to use instead of calculating.

Returns:

The computed instance transform matrix.

houdini_core_tools.math.matrix_is_identity(matrix: hou.Matrix3 | hou.Matrix4) bool[source]

Check if the matrix is the identity matrix.

Parameters:

matrix – The matrix to check.

Returns:

Whether the matrix is the identity matrix.

houdini_core_tools.math.matrix_set_translates(matrix: hou.Matrix4, translates: tuple[float, float, float] | hou.Vector3) None[source]

Set the translation values of this matrix.

Parameters:
  • matrix – The matrix to set the translations for.

  • translates – The translation values to set.

houdini_core_tools.math.vector_component_along(vector: hou.Vector3, target_vector: hou.Vector3) float[source]

Calculate the component of this vector along the target vector.

Parameters:
  • vector – The vector whose component along we want to get.

  • target_vector – The vector to calculate against.

Returns:

The component of this vector along the other vector.

houdini_core_tools.math.vector_compute_dual(vector: hou.Vector3) hou.Matrix3[source]

Compute the dual of the vector.

The dual is a matrix which acts like the cross product when multiplied by other vectors.

The following are equivalent:
  • A = vector_compute_dual(a) ; c = b * A.transposed()

  • c = cross(a, b)

Parameters:

vector – The vector to compute the dual for

Returns:

The dual of the vector.

houdini_core_tools.math.vector_contains_nans(vector: hou.Vector2 | hou.Vector3 | hou.Vector4) bool[source]

Check if the vector contains NaNs.

Parameters:

vector – The vector to check for NaNs.

Returns:

Whether there are any NaNs in the vector.

houdini_core_tools.math.vector_project_along(vector: hou.Vector3, target_vector: hou.Vector3) hou.Vector3[source]

Calculate the vector projection of this vector onto another vector.

This is an orthogonal projection of this vector onto a straight line parallel to the supplied vector.

Parameters:
  • vector – The vector to project.

  • target_vector – The vector to project onto.

Returns:

The vector projected along the other vector.

Raises:

ValueError – If the target vector is the zero vector.

houdini_core_tools.menus module

Functions and tools to deal with Houdini parameter menus.

houdini_core_tools.menus.SEPARATOR_TOKEN = '__separator__'

This is the token Houdini will use to define a separator in a menu parameter.

houdini_core_tools.menus.SEPARATOR_VALUE = ''

The value doesn’t actually matter for a separator so just use an empty string.

houdini_core_tools.menus.format_label_for_icon(label: str, icon_name: str) str[source]

Format a menu label to include an icon.

Parameters:
  • label – The menu label value.

  • icon_name – The icon to use.

Returns:

The formatted label value.

houdini_core_tools.menus.format_orange_label_text(label: str) str[source]

Format a menu label to be orange.

Parameters:

label – The menu label value.

Returns:

The formatted label value.

houdini_core_tools.menus.get_menu_separator_entry() tuple[str, str][source]

Get the required token and value to add a separator to a parameter menu.

Returns:

The separator token and value pair.

houdini_core_tools.menus.make_houdini_menu(pre_items: Sequence[tuple[str, str]] | None = None, *, add_separator: bool = False) Callable[source]

Function decorator which takes a list of strings and converts it to a Houdini style menu.

>>> @make_houdini_menu(pre_items=[('z', 'y')], add_separator=True)
... def menu_builder():
...     return ['a', 'b', 'c']
...
>>> print(menu_builder())
['z', 'y', '__separator__', '', 'a', 'a', 'b', 'b', 'c', 'c']
Parameters:
  • pre_items – Optional items to insert before the generated values.

  • add_separator – Whether to add a separator after the pre-item entries.

Returns:

The wrapped function.

houdini_core_tools.nodegraph module

Functions and tools for dealing with the node graph.

enum houdini_core_tools.nodegraph.NodeGraphTitleLocation(value)[source]

Bases: Enum

Enum for selecting the title location.

Valid values are as follows:

LEFT = <NodeGraphTitleLocation.LEFT: 'left'>
RIGHT = <NodeGraphTitleLocation.RIGHT: 'right'>
class houdini_core_tools.nodegraph.NodeGraphTitleManager(*args, **kwargs)[source]

Bases: object

Manager for setting node graph titles.

reset_title(location: NodeGraphTitleLocation) None[source]

Reset the left title to the default.

Parameters:

location – The title location to reset.

set_dynamic_title(location: NodeGraphTitleLocation, value_func: Callable, *, include_default: bool = True) None[source]

Set a dynamic title value for the selected title field.

The value function will be called whenever the node graph is refreshed.

Parameters:
  • location – The title location to modify.

  • value_func – A callable to provide the title value.

  • include_default – Whether to include the default title information.

set_static_title(location: NodeGraphTitleLocation, value: str, *, include_default: bool = True) None[source]

Set a static title value for the left title field.

Parameters:
  • location – The title location to modify.

  • value – The value to set.

  • include_default – Whether to include the default title information.

houdini_core_tools.nodes module

Functions related to Houdini nodes.

houdini_core_tools.nodes.disconnect_all_inputs(node: hou.Node) None[source]

Disconnect all the node’s inputs.

Parameters:

node – The node to disconnect all inputs for.

houdini_core_tools.nodes.disconnect_all_outputs(node: hou.Node) None[source]

Disconnect all of this node’s outputs.

Parameters:

node – The node to disconnect all outputs for.

houdini_core_tools.nodes.get_containing_node(node: hou.Node) hou.Node | None[source]

Returns the nearest parent node which is of a different node type category.

Parameters:

node – The node to find the containing node of.

Returns:

The containing node.

houdini_core_tools.nodes.get_node_author(node: hou.OpNode) str[source]

Get the name of the node creator.

Parameters:

node – The node to get the author of.

Returns:

The author name.

houdini_core_tools.nodes.get_nodes_from_paths(paths: Sequence[str]) tuple[hou.Node, ...][source]

Convert a list of string paths to hou.Node objects.

Parameters:

paths – A list of paths.

Returns:

A tuple of hou.Node objects.

houdini_core_tools.nodes.get_node_type_tool(node_or_node_type: hou.Node | hou.NodeType) hou.Tool | None[source]

Get the hou.Tool entry for a particular node or node type.

Parameters:

node_or_node_type – The node or node type to get the tool for.

Returns:

The node type tool, if any.

houdini_core_tools.nodes.node_is_contained_by(node: hou.Node, containing_node: hou.Node) bool[source]

Test if a node is a contained within another node.

Parameters:
  • node – The node to check for being contained.

  • containing_node – A node which may contain this node

Returns:

Whether this node is a child of the passed node.

houdini_core_tools.nodes.read_from_user_data(node: hou.Node, user_data_name: str) Any[source]

Read a data structure stored in a node’s user data dictionary.

Use this in conjunction with store_as_user_data.

Parameters:
  • node – The node the data is stored on.

  • user_data_name – The user data key the data is stored under.

Returns:

The stored data.

houdini_core_tools.nodes.store_as_user_data(node: hou.Node, user_data_name: str, data: Any) None[source]

Store a data structure in a node’s user data dictionary.

Use this in conjunction with read_from_user_data.

The structure to be stored must be encodable by json.

Parameters:
  • node – The node to store the data on.

  • user_data_name – The user data key to store the data under.

  • data – The data to store.

houdini_core_tools.parameters module

Functions and tools to deal with Houdini parameters.

houdini_core_tools.parameters.eval_multiparm_instance(node: hou.OpNode, name: str, indices: list[int] | tuple[int] | int, *, raw_indices: bool = False) tuple | float | str | hou.Ramp[source]

Evaluate a multiparm parameter by indices.

The name should include the # value(s) which will be replaced by the indices.

The index should be the multiparm index, not including any start offset.

You cannot try to evaluate a single component of a tuple parameter, evaluate the entire tuple instead and get which values you need.

# Float >>> eval_multiparm_instance(node, “float#”, 1) 0.53 # Float 3 >>> eval_multiparm_instance(node, “vec#”, 1) (0.53, 1.0, 2.5)

Parameters:
  • node – The node to evaluate the parameter on.

  • name – The base parameter name.

  • indices – The multiparm indices.

  • raw_indices – Whether the indices are ‘raw’ and should not try and take the folder offset into account.

Returns:

The evaluated parameter value.

Raises:
houdini_core_tools.parameters.eval_parm_as_strip(parm: hou.Parm) tuple[bool, ...][source]

Evaluate the parameter as a Button/Icon Strip.

Returns a tuple of True/False values indicated which buttons are pressed.

Parameters:

parm – The parm to eval.

Returns:

True/False values for the strip.

Raises:

ParameterNotAButtonStripError – If the parameter is not a button strip.

houdini_core_tools.parameters.eval_parm_strip_as_string(parm: hou.Parm) tuple[str, ...][source]

Evaluate the parameter as a Button Strip as strings.

Returns a tuple of the string tokens which are enabled.

Parameters:

parm – The parm to eval.

Returns:

String token values.

houdini_core_tools.parameters.eval_parm_tuple_as_color(parm_tuple: hou.ParmTuple) hou.Color[source]

Evaluate a color parameter and return a hou.Color object.

Parameters:

parm_tuple – The parm tuple to eval.

Returns:

The evaluated parameter as a hou.Vector*

Raises:

ParmTupleTypeError – If the parm tuple is not a color.

houdini_core_tools.parameters.eval_parm_tuple_as_vector(parm_tuple: hou.ParmTuple) hou.Vector2 | hou.Vector3 | hou.Vector4[source]

Return the parameter value as a hou.Vector of the appropriate size.

Parameters:

parm_tuple – The parm tuple to eval.

Returns:

The evaluated parameter as a hou.Vector*

Raises:

ParmTupleTypeError – If the parm tuple is not a vector type (XYZW).

houdini_core_tools.parameters.find_matching_parent_parm(parm: hou.Parm, *, stop_at_locked_hda: bool = True) hou.Parm | None[source]

Look for a parameter of the same name on any parent node.

Parameters:
  • parm – The reference parameter whose name to search for.

  • stop_at_locked_hda – Whether to stop if a parent is a locked HDA.

Returns:

The matching parent parameter, if any.

houdini_core_tools.parameters.find_parameters_using_variable(variable: str) tuple[hou.Parm, ...][source]

Find parameters which contain a variable.

This only works for string parameters

The variable name can be supplied with or without a $.

Variable usage that includes {} to help with disambiguation will also be automatically found.

This will match only the exact usage. For example, if you search for $HIP the result would not include any parameters using $HIPNAME or $HIPFILE.

Parameters:

variable – The variable name to search for.

Returns:

A tuple of parameters which contain the variable.

houdini_core_tools.parameters.find_parameters_with_value(target_value: str) tuple[hou.Parm, ...][source]

Find parameters which contain the target value.

This only works for string parameters.

Parameters:

target_value – The value to search for.

Returns:

A tuple of parameters which contain the value.

houdini_core_tools.parameters.get_multiparm_containing_folders(name: str, parm_template_group: hou.ParmTemplateGroup) tuple[hou.FolderParmTemplate, ...][source]

Given a parameter template name, return a list of containing multiparms.

If the name is contained in one or more multiparm folders, the returned templates will be ordered from innermost to outermost

|_ outer
|_ inner#

|_ param#_#

In a situation like above, querying for containing folders of param#_# would result in a tuple ordered as follows: (<hou.FolderParmTemplate inner#>, <hou.FolderParmTemplate outer>)

Parameters:
  • name – The name of the parameter to get the containing names for.

  • parm_template_group – A parameter template group for a nde.

Returns:

A tuple of containing multiparm templates, if any.

houdini_core_tools.parameters.get_multiparm_container_offsets(name: str, parm_template_group: hou.ParmTemplateGroup) tuple[int, ...][source]

Given a parameter template name, return a list of containing multiparm folder offsets.

If the name is contained in one or more multiparm folders, the returned offsets will be ordered outermost to innermost

|_ outer (starting offset 0)
|_ inner# (starting offset 1)

|_ param#_#

In a situation like above, querying for containing offsets of param#_# would result in a tuple ordered as follows: (0, 1)

Parameters:
  • name – The name of the parameter to get the containing offsets for.

  • parm_template_group – A parameter template group for a nde.

Returns:

A tuple of containing multiparm offsets, if any.

houdini_core_tools.parameters.get_multiparm_siblings(parm: hou.Parm | hou.ParmTuple) dict[source]

Get a tuple of any sibling parameters in the multiparm block.

Parameters:

parm – The parameter to get any siblings for.

Returns:

Any sibling parameters.

Raises:

ParameterIsNotAMultiParmInstanceError – If the parm is not a multiparm instance.

houdini_core_tools.parameters.get_multiparm_start_offset(parm_template: hou.ParmTemplate) int[source]

Get the start offset of items in the multiparm.

Parameters:

parm_template – A multiparm folder parm template

Returns:

The start offset of the multiparm.

Raises:

ParameterTemplateIsNotAMultiParmError – If the template is not a multiparm.

houdini_core_tools.parameters.get_multiparm_template_name(parm: hou.Parm | hou.ParmTuple) str | None[source]

Return a multiparm instance’s parameter template name.

Parameters:

parm – The parm to get the multiparm instances values for.

Returns:

The parameter template name, or None

houdini_core_tools.parameters.is_parm_multiparm(parm: hou.Parm | hou.ParmTuple) bool[source]

Check if this parameter is a multiparm.

Parameters:

parm – The parm or tuple to check for being a multiparm.

Returns:

Whether the parameter is a multiparm.

houdini_core_tools.parameters.is_parm_template_multiparm_folder(parm_template: hou.ParmTemplate) bool[source]

Returns True if the parm template represents a multiparm folder type.

Parameters:

parm_template – The parameter template to check.

Returns:

Whether the template represents a multiparm folder.

houdini_core_tools.parameters.is_parm_tuple_color(parm_tuple: hou.ParmTuple) bool[source]

Check if the parameter is a color parameter.

Parameters:

parm_tuple – The parm tuple to check.

Returns:

Whether the parameter tuple is a color.

houdini_core_tools.parameters.is_parm_tuple_vector(parm_tuple: hou.ParmTuple) bool[source]

Check if the tuple is a vector parameter.

Parameters:

parm_tuple – The parm tuple to check.

Returns:

Whether the parameter tuple is a vector.

houdini_core_tools.parameters.resolve_multiparm_tokens(name: str, indices: int | list[int] | tuple[int, ...]) str[source]

Resolve a multiparm token string with the supplied indices.

Parameters:
  • name – The parameter name.

  • indices – One or mode multiparm indices.

Returns:

The resolved string.

houdini_core_tools.parameters.unexpanded_string_multiparm_instance(node: hou.OpNode, name: str, indices: list[int] | int, *, raw_indices: bool = False) tuple[str, ...] | str[source]

Get the unexpanded string of a multiparm parameter by index.

The name should include the # value which will be replaced by the index.

The index should be the multiparm index, not including any start offset.

You cannot try to evaluate a single component of a tuple parameter, evaluate the entire tuple instead and get which values you need.

# String >>> eval_multiparm_instance(node, “string#”, 1) ‘$HIP’ # String 2 >>> eval_multiparm_instance(node, “stringvec#”, 1) (‘$HIP’, ‘$PI’)

Parameters:
  • node – The node to evaluate the parameter on.

  • name – The base parameter name.

  • indices – The multiparm indices.

  • raw_indices – Whether the indices are ‘raw’and should not try and take the folder offset into account.

Returns:

The evaluated parameter value.

Raises:

Module contents