Skip to main content

Scene Objects

The rpd module defines the scene objects that the rpts functions return and accept. Objects are usually reached through get_asset() or through a node's children, rather than created directly. Access them as rpd.<Name>, or use the objects that rpts returns.

Asset​

rpd.Asset represents an imported 3D asset. It contains the scene hierarchy, including nodes, meshes, materials and metadata. Use root_node to reach the hierarchy. Use meshes and materials to query meshes and materials by index.

Properties​

  • root_node (Node): the root node of the scene hierarchy.
  • meshes (read-only iterable of Mesh): every mesh in the asset.
  • materials (read-only iterable of Material): every material in the asset.
  • num_meshes (int): the number of meshes in the asset.
  • num_materials (int): the number of materials in the asset. The Sphinx docstring for this property says "number of meshes", which appears to be a copy error in the source.
  • num_triangles (int): the total number of triangles across all meshes.

Methods​

mesh(index)​

Returns the mesh at the given index.

  • index (int): the zero-based mesh index.

Returns: a Mesh.

material(index)​

Returns the material at the given index.

  • index (int): the zero-based material index.

Returns: a Material.

node_at_path(path)​

Returns the node at the given path.

  • path (str): the node path.

Returns: the Node at that path, or None if it does not exist.

destroy_mesh(index)​

Destroys the mesh with the given index.

  • index (int): the zero-based mesh index.

destroy_empty_meshes()​

Destroys every mesh that contains no polygons.

destroy_empty_nodes()​

Destroys empty leaf nodes.

destroy_unreferenced_materials()​

Destroys every material that no mesh references.

destroy_unreferenced_meshes()​

Destroys every mesh that no node references.

Not described in the Sphinx output

The Sphinx output lists query_nodes and wrap as members of Asset, but gives no description or signature for either. They are not documented here.

Node​

rpd.Node represents a node in the scene hierarchy. Each node has a parent and zero or more children. A node can reference a mesh and a skin, store a transform, and hold metadata.

Each node has a path, a /-separated string that identifies its position in the tree, for example group/part_003. A node that carries geometry exposes that geometry as a mesh at its own path with /mesh added. Children can be reached by index, for example child = node[0], and len(node) returns the number of children.

Properties​

  • name (str): the node name.
  • id: the unique identifier of the node.
  • path (str): the full hierarchical path of the node.
  • parent (Node or None): the parent node. This is None for the root node.
  • children (read-only iterable of Node): the children of this node.
  • mesh_index (int): the index of the mesh this node references. -1 if no mesh is assigned.
  • skin_index (int): the index of the skin this node references. -1 if no skin is assigned.
  • transform (Matrix4): the transform matrix of the node.
  • metadata (Metadata): the metadata attributes of the node.
  • selected (bool): True if the node is currently selected in the tree or viewport. This is the same state that rpts.is_node_selected() reports.
  • visible (bool): True if the node's own visibility flag is not hidden. This checks only the node itself, not its ancestors. This is the same state that rpts.is_node_visible() reports.

Methods​

child_index(child)​

Returns the zero-based index of a child node.

  • child (Node): the child node to locate.

Returns: an int.

compute_world_transform()​

Computes the world transform matrix for this node. The Sphinx output gives no parameters and does not describe a return type beyond the matrix.

create_child(name)​

Creates a new child node and attaches it to this node.

  • name (str): the name of the new node.

Returns: the new Node.

create_path(path)​

Creates nodes along a hierarchy path. Any missing intermediate nodes are created.

  • path (str): the hierarchical node path.

Returns: the Node at the requested path.

destroy_child(child)​

Removes a child node and destroys it.

  • child (Node): the child node to remove.

Mesh​

rpd.Mesh represents a mesh geometry resource. A mesh holds vertex and triangle data, and it can reference one or more materials. Meshes are usually reached through nodes in the scene hierarchy.

Properties​

  • name (str): the name of the mesh.
  • num_vertices (int): the number of vertices in the mesh.
  • num_triangles (int): the number of triangles in the mesh.
  • num_materials (int): the number of materials that the mesh references.

Methods​

compute_aabb()​

Computes the axis-aligned bounding box of the mesh. The Sphinx output does not name the return type. It describes the return value only as "the AABB of the mesh". See BBox for the axis-aligned bounding box class.

Returns: the axis-aligned bounding box of the mesh.

material_index(index)​

Returns the material index assigned to a material slot.

  • index (int): the zero-based material slot index.

Returns: an int, the material index.

set_material(material_index)​

Sets the given material index as the only material of this mesh.

  • material_index (int): the zero-based material index.

remove_uvs(uv_set_index)​

Removes a UV set from the mesh.

  • uv_set_index (int): the index of the UV set to remove. Pass -1 to remove all UV sets.

Material​

rpd.Material represents a material resource.

Properties​

  • name (str): the name of the material.

BBox​

rpd.BBox is an axis-aligned bounding box. It is defined by two corners, min (the lowest x, y and z values) and max (the highest x, y and z values). Coordinates are stored as single-precision floating-point values.

bbox = rpd.BBox()
bbox.min = (0.0, 0.0, 0.0)
bbox.max = (1.0, 2.0, 3.0)

A bounding box is axis-aligned and does not represent a rotated bounds. After you apply a transform to geometry, recompute the bounds.

Properties​

  • min (Vec3): the minimum corner.
  • max (Vec3): the maximum corner.
Not described in the Sphinx output

The Sphinx output lists transformed as a member of BBox, but gives no description or signature. It is not documented here.

NodeFilter​

rpd.NodeFilter defines a filter that selects nodes in a scene. A filter sets the property to examine, the comparison to use, and the pattern to match against.

Properties​

  • target (NodeFilterTarget): the property to examine.
  • match_type (FilterMatchType): the comparison method.
  • pattern (str): the string pattern to match against.
  • case_sensitive (bool): whether matching considers letter case.
note

The Sphinx output does not show a constructor signature for NodeFilter, and it does not show how a filter is passed to a function. None of the functions listed in this reference accept a NodeFilter.

FilterMatchType​

rpd.FilterMatchType is an enum. It defines how a filter compares a target value against a query string.

  • REGEX = 0: the pattern is a regular expression.
  • EXACT = 1: the value must equal the pattern.
  • CONTAINS = 2: the value must contain the pattern.
  • STARTS_WITH = 3: the value must start with the pattern.
  • ENDS_WITH = 4: the value must end with the pattern.

NodeFilterTarget​

rpd.NodeFilterTarget is an enum. It specifies which node property a filter examines.

  • NODE_NAME = 0: the node name.
  • MESH_NAME = 1: the mesh name.
  • MATERIAL_NAME = 2: the material name.
  • METADATA_PATH = 3: the metadata path.
  • METADATA_ATTRIB_TITLE = 4: the title of a metadata attribute.
  • METADATA_SUB_ATTRIB_TITLE = 5: the title of a metadata sub-attribute.

QueryMode​

rpd.QueryMode is an enum. It defines how multiple filter conditions are combined.

  • MATCH_ALL = 0: a node must satisfy all conditions.
  • MATCH_ANY = 1: a node must satisfy at least one condition.

Metadata​

rpd.Metadata is a view of the metadata attributes that belong to a node. Read it from Node.metadata. You can access attributes by index, by title, or by iterating over them. len(metadata) returns the number of attributes.

for attribute in metadata:
print(attribute.title)

material = metadata["Material"]

MetadataAttribute​

rpd.MetadataAttribute is a metadata attribute. It has a title and can hold integer, floating-point and string values.

Properties​

  • title (str): the name or identifier of the attribute.
  • uints (list of MetadataSubAttributeUInt32): the integer-valued entries.
  • floats (list of MetadataSubAttributeFloat): the floating-point-valued entries.
  • strings (list of MetadataSubAttributeString): the string-valued entries.

Each sub-attribute has a title and a value. The value is an int, a float or a str, depending on the sub-attribute type.

note

The Sphinx output lists the integer entries as MetadataSubAttributeUInt in one place and as MetadataSubAttributeUInt32 in another. This page uses MetadataSubAttributeUInt32, which is the name the property signature gives.

RpdUnwrapMode​

rpts.RpdUnwrapMode is an enum that the Sphinx output lists under rpts. It is listed here because its values appear in the Sphinx output. None of the functions documented in this reference use it.

  • RPD_UNWRAP_ISOMETRIC = 0
  • RPD_UNWRAP_CUBE = 1
  • RPD_UNWRAP_PLANE_XY = 2
  • RPD_UNWRAP_PLANE_YZ = 3
  • RPD_UNWRAP_PLANE_XZ = 4
  • RPD_UNWRAP_SPHERE_X = 5
  • RPD_UNWRAP_SPHERE_Y = 6
  • RPD_UNWRAP_SPHERE_Z = 7
  • RPD_UNWRAP_CYLINDER_X = 8
  • RPD_UNWRAP_CYLINDER_Y = 9
  • RPD_UNWRAP_CYLINDER_Z = 10
  • RPD_UNWRAP_PACKED_CUBE = 11