Copy
SUMMARY
copy deep-copies the tree and applies an optional prefix/suffix to every frame name, so the copy can coexist with the original without name collisions.
The Skill
python
tree_copy = tree.copy(prefix="copy_")Example

The original tree alongside its deep copy, coexisting under a renamed root.
The Code
python
"""
Example of TransformTree.copy.
"""
from loguru import logger
from telekinesis.tf import tftree
def main():
"""
Deep copy a tree with a renamed root.
"""
tree = tftree.TransformTree("world")
tree.add("world", "camera", [0, 0, 1, 0, 0, 0], rot_type="deg")
tree_copy = tree.copy(prefix="copy_")
logger.info(f"Original root: {tree.get_root_name()}")
logger.info(f"Copy root: {tree_copy.get_root_name()}")
logger.info(f"Copy frames: {list(tree_copy.get_all_frames(reference_node_name=tree_copy.get_root_name()).keys())}")
tree.visualize_rerun(axis_len=0.5)
tree_copy.visualize_rerun(axis_len=0.5)
if __name__ == "__main__":
main()Parameter Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
prefix | str | "" | Prefix added to every frame name in the copy, including the root. |
suffix | str | "" | Suffix added to every frame name in the copy, including the root. |
Returns
| Type | Description |
|---|---|
TransformTree | A deep copy of the tree, with prefix/suffix applied to every frame name. |
Raises
| Exception | Condition |
|---|---|
TypeError | prefix is not a string. |
TypeError | suffix is not a string. |

