Skip to main content

Top-Level Functions

All functions on this page are attributes of the rpts module. In external Python, call them as rpts.get_selection() after import rpts. In the RPTS console, rpts is already available.

Getting the asset and the selection​

get_asset()​

Returns the asset currently loaded in the application.

Returns: the current asset as an Asset instance, or None if no model is loaded.

get_selection(as_paths=False)​

Returns the currently selected nodes.

  • as_paths (bool): pass True to get the raw list of selected path strings instead of Node objects. Default: False.

Returns: a list of Node objects by default, or a list of str paths if as_paths=True.

get_selected_nodes()​

Returns the currently selected nodes. This is an alias of get_selection().

Returns: always a list of Node objects.

get_unselected_nodes()​

Returns every node in the scene whose path is not currently selected. If a selected node is a mesh, its owning node is also excluded from the result.

Returns: a list of Node objects.

set_selection(nodes)​

Replaces the current scene selection with exactly the given node or nodes. The change appears immediately in the scene tree and the viewport.

  • nodes (str, Node, or iterable of either): a single path, a single rpd.Node, or an iterable of either.

select_nodes(nodes)​

Adds one or more nodes to the current selection. The change appears immediately in the scene tree and the viewport.

  • nodes (str, Node, or iterable of either): a single path, a single rpd.Node, or an iterable of either.

deselect_nodes(nodes)​

Removes one or more nodes from the current selection. The change appears immediately in the scene tree and the viewport.

  • nodes (str, Node, or iterable of either): a single path, a single rpd.Node, or an iterable of either.

set_nodes_selected(nodepaths, selected)​

Selects or deselects the nodes at the given paths.

  • nodepaths (list of str): scene node paths. Unlike select_nodes() and deselect_nodes(), this does not accept a single path, a single Node, or Node objects. Pass a list of path strings.
  • selected (bool): True to select the nodes, False to deselect them.

Returns: an int that reports how many nodes changed:

  • -1 if none of the given paths could be resolved to a scene node.
  • 0 if every resolved node was already in the requested state, so nothing changed.
  • A number greater than 0: the number of nodes whose selection state actually changed.

is_node_selected(nodepath)​

Returns whether the node at the given path is currently selected. This is the function behind the selected property of rpd.Node.

  • nodepath (str or Node): a scene node path or an rpd.Node.

Returns: True if the node is currently selected, otherwise False.

Visibility​

get_hidden_nodes(effective=False, as_paths=False)​

Returns the explicitly hidden nodes.

  • effective (bool): False returns exactly the nodes that are explicitly hidden. True also includes every descendant of a hidden node, because the renderer does not draw those either. Default: False.
  • as_paths (bool): True returns a list of path strings instead of Node objects. Default: False.

Returns: a list of Node objects, or a list of str paths if as_paths=True.

get_visible_nodes(effective=False, as_paths=False)​

Returns the complement of get_hidden_nodes(), that is, the nodes that are not hidden.

  • effective (bool): see the note below. Default: False.
  • as_paths (bool): True returns a list of path strings instead of Node objects. Default: False.

Returns: a list of Node objects, or a list of str paths if as_paths=True.

note

The Sphinx output describes as_paths for this function but does not describe effective. For what effective does, see get_hidden_nodes() above, which this function complements.

hide_nodes(nodes)​

Hides one or more nodes. The hidden state applies to each node's whole subtree. The change appears immediately in the scene tree and the viewport.

  • nodes (str, Node, or iterable of either): a single path, a single rpd.Node, or an iterable of either.

show_nodes(nodes)​

Shows one or more nodes. The change applies to each node's whole subtree and to all of its ancestors, because a node cannot render while an ancestor is hidden. The change appears immediately in the scene tree and the viewport.

  • nodes (str, Node, or iterable of either): a single path, a single rpd.Node, or an iterable of either.

set_nodes_visible(nodepaths, visible)​

Shows or hides the nodes at the given paths, including their subtrees.

  • nodepaths (list of str): scene node paths. Unlike hide_nodes() and show_nodes(), this does not accept a single path, a single Node, or Node objects. Pass a list of path strings.
  • visible (bool): True to show the nodes, False to hide them.

Returns: an int that reports how many nodes changed:

  • -1 if none of the given paths could be resolved to a scene node.
  • 0 if every resolved node was already in the requested state, so nothing changed.
  • A number greater than 0: the number of nodes whose visibility state actually changed.

is_node_visible(nodepath)​

Returns whether the node's own visibility flag is not hidden. This checks only the node itself. It does not check whether an ancestor is hidden. To include hidden ancestors, use get_hidden_nodes(effective=True). This function is the one behind the visible property of rpd.Node.

  • nodepath (str): a single scene node path. Unlike most functions on this page, this does not accept an rpd.Node or an iterable.

Returns: True if the node's own visibility flag is not hidden, otherwise False.

Deletion and cleanup​

danger

Deletion is not undoable, and it does not clear the undo stack.

delete_nodes(nodes)​

Deletes one or more nodes from the scene. The scene tree is refreshed once after all deletions. The function prints a one-line summary.

  • nodes (str, Node, or iterable of either): a single path, a single rpd.Node, or an iterable of either. A bare string is treated as a single path, not as an iterable of characters.

Returns: a list of the deleted paths.

delete_empty_nodes()​

Deletes every node whose subtree contains no mesh. A node counts as empty when it has no mesh of its own and every one of its children is also empty. The function deletes the largest such subtrees. It prints a one-line summary.

Returns: a list of the deleted paths.

delete_hidden_nodes()​

Deletes every explicitly hidden node. The function reduces the targets to the largest hidden subtrees first. Deleting a subtree root already removes every hidden node beneath it, so those descendants are not deleted separately.

Returns: a list of the deleted paths.

rename_long_names(max_len=128)​

Walks every node in the scene. For each node whose name is longer than max_len characters, it truncates the name to max_len. After truncation, two sibling nodes can end up with the same name, so the function appends a numeric suffix (_1, _2, and so on) to make sibling names unique. The suffix is added within the length limit. The function refreshes the scene tree once at the end and prints a one-line summary.

  • max_len (int): names longer than this are truncated to this length. Default: 128.

Returns: a list of (path, old_name, new_name) tuples for the nodes that were renamed.

Processing​

list_actions()​

Returns the available processing actions, with the name and parameters of each.

Returns: a list of dicts, each with a name and a params mapping. Each entry in params has a description and a path:

[
{
"name": "Decimate Mesh",
"params": {
"face_target": {"description": "...", "path": "..."},
"deviation_percentage": {"description": "...", "path": "..."},
},
},
]

process_action(action, params=None)​

Runs a processing action on the current model.

  • action (str): the action name as it appears in meta.json, for example 'Decimate Mesh'.
  • params (dict): parameter values. Each key can be the snake_case form of the parameter name (for example 'face_target'), the original display name (for example 'Face Target'), or the raw dot-path of the parameter. Default: None.

The Sphinx output does not describe a return value for this function.

rpts.process_action("Decimate Mesh", params={"face_target": 5000, "preserve_topology": True})

process_asset_selection(nodepaths_or_nodes, invert_selection, config)​

Runs a processing action scoped to a subset of nodes. It works like process_action(), but applies only to the given nodes. If invert_selection is True, it applies to every node that is not in the given set.

  • nodepaths_or_nodes (list of str, or list of Node): the nodes to process. Unlike process_action() and most other functions on this page, this does not accept a single path or a single Node. Pass a list.
  • invert_selection (bool): True to apply the processing to every node not in nodepaths_or_nodes, False to apply it to those nodes.
  • config (str): a JSON processing config string, in the same format that process_action() uses. Pass an empty string to reuse the processor configuration already set on the asset.

Returns: True on success.

Reimport and scene tree​

reimport_asset(config)​

Reimports the current asset using the given JSON import config.

  • config (str): a JSON import config string.

Returns: the reimported asset as an rpd.Asset instance, or None on failure.

refresh_scene_tree()​

Forces the scene tree and the viewport UI to refresh from the current native scene state. The Sphinx output does not describe a return value for this function.