MovePrimCommand#

class omni.usd.commands.MovePrimCommand(
path_from: str | Path,
path_to: str | Path,
time_code: TimeCode = Usd.TimeCode.Default(),
keep_world_transform: bool = True,
on_move_fn: Callable[[Path, Path], None] | None = None,
destructive=True,
stage_or_context: str | Stage | UsdContext | None = None,
resolve_reference: bool = True,
)#

Bases: Command

Moves a primitive to a new path.

This command moves a primitive from a old path to a new path. It can be used to re-organize the stage hierarchy. It supports two kinds of move: destructive and non-destructive. Destructive move means it will move opinions of the prim to the new path in all layers from the local layer stack instead of touching the current edit target only. Non-destructive move means it will not touch other layers instead of the current edit target only by merging all opinions from all local layers and moving them to the new path. It deactivates the old path instead of removing it depending on the condition if it will break the principle of non-destrutive authoring. Due to historical reason, this command is built with destuctive move so destructive move is enabled by default. It’s recommended to use non-destructive move to ensure the command only influences the current edit target. REMINDER: Moving primitive to change stage’s hierarchy in USD is a heavy operation that may trigger big composition cost.

Methods

__init__(path_from, path_to[, time_code, ...])

Constructor.

do()

modify_callback_info(cb_type, cmd_args)

Returns a dictionary of information to be passed to callbacks of the given type.

undo()

__init__(
path_from: str | Path,
path_to: str | Path,
time_code: TimeCode = Usd.TimeCode.Default(),
keep_world_transform: bool = True,
on_move_fn: Callable[[Path, Path], None] | None = None,
destructive=True,
stage_or_context: str | Stage | UsdContext | None = None,
resolve_reference: bool = True,
)#

Constructor.

Parameters:
  • path_from (str) – Path to move prim from.

  • path_to (str) – Path to move prim to.

  • time_code (Usd.TimeCode, optional) – Current timecode of the stage. Default is Usd.TimeCode.Default().

  • keep_world_transform (bool, optional) – True to keep world transform after prim path is moved. False to keep local transfrom only. Default is True.

  • on_move_fn (Callable[[Sdf.Path, Sdf.Path], None], optional) – Function to call when prim is renamed, that the first param is the source path, and second one is the target path. Default is None.

  • destructive (bool, optional) – If it’s false, it will not remove original prim but deactivate it. Default is True for back compatibility.

  • stage_or_context – (Union[str, Usd.Stage, omni.usd.UsdContext]): Stage or UsdContext applies the changes to. It can be instance of Usd.Stage or omni.usd.UsdContext, or context name. By default, it will apply the changes to the stage in default UsdContext.

  • resolve_reference (bool, optional) – If to resolve primitive’s references after prim is moved to new path.

modify_callback_info(
cb_type: str,
cmd_args: Dict[str, Any],
) Dict[str, Any]#

Returns a dictionary of information to be passed to callbacks of the given type.

By default callbacks are passed a copy of the arguments which were passed to execute() when the command was invoked. This method can be overridden to modify that information for specific callback types.

Parameters:
  • cb_type – Type of callback the information will be passed to.

  • args – A dictionary containing a copy of the arguments with which the command was invoked. This is a shallow copy so implementations may add, remove or replace dictionary elements but should not modify any of the objects contained within it.

Returns:

A dictionary of information to be passed to callbacks of the specified type.