Clash Detection Anim API#

The Clash Detection Anim extension (included in the Clash Detection Bundle extension) is an API that provides functionality for recording animation curves within a USD stage. It captures transform animations (translate, rotate, scale) from animated prims and saves them as time samples in a USD session layer (by default “ClashStageRecordedData” layer).

AnimRecorder#

class AnimRecorder#

A class for recording animation curves within a USD stage.

This class utilizes the ICurveAnimRecorder interface to record animation curves over a specified time range for a given set of USD prims. It supports functionalities such as starting and stopping recordings, resetting session properties, and configuring recording attributes.

Methods#

destroy()#

Releases the stage recorder interface and cleans up the recorder API.

reset_overridden_session_prim_props()#

Resets overridden session prim properties.

get_recording_session_layer_name() str#

Gets the name of the recording session layer.

Returns:

The name of the recording session layer.

Return type:

str

run(
stage: Usd.Stage,
prims_int_path: List[int],
start_time: float,
end_time: float,
fps: float,
) Generator[float, None, None]#

Records animation curves for the given prims from start_time to end_time at the specified fps. The recording is saved to a session layer that can be accessed via get_recording_session_layer_name(). Yields the current timeline time in seconds as recording progresses.

Parameters:
  • stage (Usd.Stage) – The USD stage containing the prims to record.

  • prims_int_path (List[int]) – List of integer prim paths to record.

  • start_time (float) – Start time in seconds.

  • end_time (float) – End time in seconds.

  • fps (float) – Frames per second for the recording.

Returns:

Yields the current time in seconds as recording progresses.

Return type:

Generator[float, None, None]

Attributes#

copy_also_unrecorded_usd_attribs_on_save#

Gets or sets whether to copy unrecorded USD attributes on save.

  • Getter: Returns True if unrecorded attributes will be copied.

  • Setter: Sets whether to copy unrecorded USD attributes on save.

Parameters:

value (bool) – If True, copies unrecorded attributes.

Usage Example#

Note

The AnimRecorder is used internally by the clash detection pipeline to convert curve animations to time-sampled data before running clash detection. You typically do not need to call it directly. The clash detection UI invokes it automatically when Dynamic clash detection is enabled for a query that contains curve-animated prims.

If you do need to call it directly, integer prim paths are obtained from get_list_of_prims_int_paths(), not from literal values.

from pxr import Usd
from omni.physxclashdetectionanim.scripts.anim_recorder import AnimRecorder
from omni.physxclashdetectioncore.clash_detect import ClashDetection

# Open a USD stage that contains curve-animated prims
stage = Usd.Stage.Open("path/to/your.usd")

# Obtain integer prim paths for the prims you want to record.
# ClashDetection.get_list_of_prims_int_paths resolves prim paths and
# optionally expands children. The Sdf.Path objects must be kept alive
# while using the integer paths.
sdf_paths, prims_int_path = ClashDetection.get_list_of_prims_int_paths(
    stage, "/World", add_prim_children=True
)

# Initialize the AnimRecorder
anim_recorder = AnimRecorder()

# Define the recording parameters
start_time = 0.0  # Start time in seconds
end_time = 10.0   # End time in seconds
fps = 24.0        # Frames per second

# Run the recording - yields current time in seconds as progress
for current_time in anim_recorder.run(stage, prims_int_path, start_time, end_time, fps):
    print(f"Recording at time: {current_time} seconds")

# The recorded data is stored in the session layer named below
session_layer_name = anim_recorder.get_recording_session_layer_name()
print(f"Recording session layer: {session_layer_name}")

# Clean up
anim_recorder.destroy()