simvx.editor.extract

Extract a node subtree to a separate Python file.

Generates a new Python module containing a class definition for a node and its children, and modifies the original source to import the new class.

Public API: node_to_class_source(node, class_name) – node subtree -> Python class source extract_node_to_file(node, source, output_path, class_name) – full extraction: new file + modified original

Module Contents

Functions

node_to_class_source

Generate Python source for a class that recreates node and its children.

extract_node_to_file

Extract a node subtree to a new Python file.

Data

log

API

simvx.editor.extract.log

‘getLogger(…)’

simvx.editor.extract.node_to_class_source(node: simvx.core.node.Node, class_name: str | None = None) str[source]

Generate Python source for a class that recreates node and its children.

Args: node: The node whose subtree to convert. class_name: Name for the generated class. Defaults to the node’s class name.

Returns: Complete Python source string for the new file.

simvx.editor.extract.extract_node_to_file(node: simvx.core.node.Node, source: str, output_path: str, class_name: str | None = None) tuple[str, str][source]

Extract a node subtree to a new Python file.

Args: node: The node to extract (must be a child of the scene root). source: The original Python source of the parent scene. output_path: File path for the new module (used to derive import path). class_name: Name for the extracted class.

Returns: (new_file_source, modified_original_source) where: - new_file_source contains the class definition with the node’s children. - modified_original_source has the inline construction replaced with an import and instantiation of the new class.