FabricDataAccessor
- class omni.kit.manipulator.prim.fabric.FabricDataAccessor(usd_context_name: str = '', model=None)
Bases:
object
A class for accessing and manipulating USD (Universal Scene Description) data in a fabric.
This class handles the retrieval and alteration of scene graph information, including transformation matrices, stage access, and USD prim manipulation. It is designed to work within a fabric-based USD runtime and provides a range of methods to interact with USD stages and prims.
- Parameters
usd_context_name (str) – The name of the USD context to associate with this data accessor. An empty string indicates no specific context.
model – The model associated with the data accessor. The exact type of the model is not specified.
This class also handles update callbacks for changes in the USD stage and provides utility functions for converting between different path and transform representations.
Methods
__init__
([usd_context_name, model])Constructor for FabricDataAccessor.
Clears the transform cache.
destroy
()Cleans up resources and references held by the FabricDataAccessor instance.
Transforms all selected prims to manipulator pivot.
do_transform_selected_prims
(paths, paths_c, ...)Transforms selected prims with the given transformations.
Frees the USD stage.
Frees the transform cache.
get_current_time_code
(currentTime)Gets the current time code.
Gets the data tag that identifies FabricDataAccessor.
Gets the local-to-world transform matrix of the USD Prim.
get_local_transform_SRT
(prim[, time])Gets the local transform SRT (scale, rotation, translation) of the USD Prim.
get_local_transform_pivot_inv
(prim[, time])Returns the inverse of the local transformation pivot for a given prim.
Gets the parent-to-world transform matrix of the USD Prim.
get_prim_at_path
(path)Returns the USD Prim at the specified path.
get_sdf_path
(path)Returns the Sdf path for the given path.
Returns the type associated with Sdf paths used in FabricDataAccessor.
Gets the USD stage.
Retrieves the up-axis of the stage.
get_string_path
(path)Converts an Sdf path to its string representation.
has_prim_at_path
(path)Checks if a prim exists at the given path.
is_a_xformable
(prim)Determines if the provided prim is a xformable prim.
is_instance_proxy
(prim)Determines if the provided prim is an instance proxy.
is_prim_active
(prim)Determines if the provided prim is active.
Checks if transformation is affected by a specific attribute.
is_valid_path
(path)Determines if the given path is a valid Sdf path.
on_ended_transform
(paths, paths_c, ...)Applies transformations to multiple prims.
path_to_int
(path)Converts an Sdf path to an integer representation.
prim_has_prefix
(path, prim_path)Checks if the given path has the specified prefix.
remove_descendent_paths
(paths)Removes descendent paths from a list of paths.
remove_update_callback
([listener])Removes the update callback for changes.
remove_update_callback_ref_prim_maker
([listener])Removes the update callback reference to the prim maker.
Sets the USD stage.
Sets up the update callback for changes.
Sets up the update callback with a reference to the prim maker function.
to_pxr_path
(path)Converts a path to a pxr.Sdf.Path type.
Updates changes in the USD stage.
Updates the transform cache.
Sets the time for the transform cache.
Attributes
Gets the initialization status of the FabricDataAccessor.
Gets the priority value of the FabricDataAccessor.
Gets the write priority value of the FabricDataAccessor.
Gets the USD context associated with the FabricDataAccessor.
- __init__(usd_context_name: str = '', model=None)
Constructor for FabricDataAccessor.
Initializes a new instance of the FabricDataAccessor with optional USD context and model.
- clear_xform_cache()
Clears the transform cache.
- destroy()
Cleans up resources and references held by the FabricDataAccessor instance.
- do_transform_all_selected_prims_to_manipulator_pivot(paths: List[str], paths_c: List[int], new_translations: List[float], new_rotation_eulers: List[float], new_rotation_orders: List[int], new_scales: List[float])
Transforms all selected prims to manipulator pivot.
- Parameters
paths (List[str]) – List of path strings for selected prims.
paths_c (List[int]) – List of path hashes for selected prims.
new_translations (List[float]) – List of new translation values for prims.
new_rotation_eulers (List[float]) – List of new rotation euler angles for prims.
new_rotation_orders (List[int]) – List of new rotation orders for prims.
new_scales (List[float]) – List of new scale values for prims.
- do_transform_selected_prims(paths: List[str], paths_c: List[int], new_translations: List[float], new_rotation_eulers: List[float], new_rotation_orders: List[int], new_scales: List[float])
Transforms selected prims with the given transformations.
- Parameters
paths (List[str]) – List of path strings for selected prims.
paths_c (List[int]) – List of path hashes for selected prims.
new_translations (List[float]) – List of new translation values for prims.
new_rotation_eulers (List[float]) – List of new rotation euler angles for prims.
new_rotation_orders (List[int]) – List of new rotation orders for prims.
new_scales (List[float]) – List of new scale values for prims.
- free_stage()
Frees the USD stage.
- free_xform_cache()
Frees the transform cache.
- get_current_time_code(currentTime: float) TimeCode
Gets the current time code.
- Parameters
currentTime (float) – The current time to get the time code for.
- Returns
The current time code.
- Return type
usdrt.Usd.TimeCode
- get_data_tag() str
Gets the data tag that identifies FabricDataAccessor.
- Returns
The data tag for FabricDataAccessor.
- Return type
str
- get_local_to_world_transform(prim: Prim) Matrix4d
Gets the local-to-world transform matrix of the USD Prim.
- Parameters
prim (
usdrt.Usd.Prim
) – The USD Prim to get the transform for.- Returns
The local-to-world transform matrix.
- Return type
usdrt.Gf.Matrix4d
- get_local_transform_SRT(prim: Prim, time: Optional[float] = None) Tuple[Vec3d, Vec3d, Vec3i, Vec3d]
Gets the local transform SRT (scale, rotation, translation) of the USD Prim.
- Parameters
prim (
usdrt.Usd.Prim
) – The USD Prim to get the transform for.time (float) – The time at which to evaluate the transform.
- Returns
The SRT components of the transform.
- Return type
Tuple[usdrt.Gf.Vec3d, usdrt.Gf.Vec3d, usdrt.Gf.Vec3i, usdrt.Gf.Vec3d]
- get_local_transform_pivot_inv(prim: Prim, time: Optional[float] = None) Matrix4d
Returns the inverse of the local transformation pivot for a given prim.
- Parameters
prim (
Usd.Prim
) – The prim to calculate the inverse transform for.time (float, optional) – The time at which to evaluate the transformation.
- Returns
The inverse of the local transformation matrix.
- Return type
Gf.Matrix4d
- get_parent_to_world_transform(prim: Prim) Matrix4d
Gets the parent-to-world transform matrix of the USD Prim.
- Parameters
prim (
usdrt.Usd.Prim
) – The USD Prim to get the transform for.- Returns
The parent-to-world transform matrix.
- Return type
usdrt.Gf.Matrix4d
- get_prim_at_path(path: Path) Prim
Returns the USD Prim at the specified path.
- Parameters
path (
usdrt.Sdf.Path
) – The path to the USD Prim.- Returns
The USD Prim at the given path.
- Return type
usdrt.Usd.Prim
- get_sdf_path(path: Path) Path
Returns the Sdf path for the given path.
- Parameters
path (
usdrt.Sdf.Path
) – The path to resolve.- Returns
The resolved Sdf path.
- Return type
usdrt.Sdf.Path
- get_sdf_path_type() type
Returns the type associated with Sdf paths used in FabricDataAccessor.
- Returns
The Sdf path type used by FabricDataAccessor.
- Return type
type
- get_stage() Stage
Gets the USD stage.
- Returns
The USD stage.
- Return type
usdrt.Usd.Stage
- get_stage_up_axis() str
Retrieves the up-axis of the stage.
- Returns
The up-axis of the stage.
- Return type
str
- get_string_path(path: Union[Path, str]) str
Converts an Sdf path to its string representation.
- Parameters
path (Union[
usdrt.Sdf.Path
, str]) – The path to convert.- Returns
The string representation of the path.
- Return type
str
- has_prim_at_path(path: Path) bool
Checks if a prim exists at the given path.
- Parameters
path (
usdrt.Sdf.Path
) – The path to check.- Returns
True if a prim exists at the path, False otherwise.
- Return type
bool
- is_a_xformable(prim: Prim) bool
Determines if the provided prim is a xformable prim.
- Parameters
prim (
usdrt.Usd.Prim
) – The prim to check.- Returns
True if it’s a xformable prim, False otherwise.
- Return type
bool
- is_instance_proxy(prim: Prim) bool
Determines if the provided prim is an instance proxy.
- Parameters
prim (
usdrt.Usd.Prim
) – The prim to check.- Returns
True if it is an instance proxy, False otherwise.
- Return type
bool
- is_prim_active(prim: Prim) bool
Determines if the provided prim is active.
- Parameters
prim (
usdrt.Usd.Prim
) – The prim to check.- Returns
True if the prim is active, False otherwise.
- Return type
bool
- is_transformation_affected_by_attr_named(sdf_path: Path) bool
Checks if transformation is affected by a specific attribute.
- Parameters
sdf_path (
usdrt.Sdf.Path
) – The Sdf path to check.- Returns
True if transformation is affected, False otherwise.
- Return type
bool
- is_valid_path(path: Any) bool
Determines if the given path is a valid Sdf path.
- Parameters
path (Any) – The path to validate.
- Returns
True if the path is valid, False otherwise.
- Return type
bool
- on_ended_transform(paths: List[str], paths_c: List[int], new_translations: List[float], new_rotation_eulers: List[float], new_rotation_orders: List[int], new_scales: List[float], old_translations: List[float], old_rotation_eulers: List[float], old_rotation_orders: List[int], old_scales: List[float])
Applies transformations to multiple prims.
- Parameters
paths (List[str]) – Paths of prims to transform.
paths_c (List[int]) – C++ compatible path representation.
new_translations (List[float]) – New translations for the prims.
new_rotation_eulers (List[float]) – New rotation angles in Euler form.
new_rotation_orders (List[int]) – New rotation orders for the prims.
new_scales (List[float]) – New scale values for the prims.
old_translations (List[float]) – Previous translations for undo functionality.
old_rotation_eulers (List[float]) – Previous rotations in Euler form for undo.
old_rotation_orders (List[int]) – Previous rotation orders for undo functionality.
old_scales (List[float]) – Previous scale values for undo functionality.
- path_to_int(path: Path) int
Converts an Sdf path to an integer representation.
- Parameters
path (
usdrt.Sdf.Path
) – The path to convert.- Returns
The integer representation of the path.
- Return type
int
- prim_has_prefix(path: Path, prim_path: Path) bool
Checks if the given path has the specified prefix.
- Parameters
path (
usdrt.Sdf.Path
) – The path to check for the prefix.prim_path (
usdrt.Sdf.Path
) – The prefix to check against the path.
- Returns
True if the path has the prefix, False otherwise.
- Return type
bool
- remove_descendent_paths(paths: List[Path]) List[Path]
Removes descendent paths from a list of paths.
- Parameters
paths (List[
usdrt.Sdf.Path
]) – The list of paths to process.- Returns
The list of paths without descendents.
- Return type
List[
usdrt.Sdf.Path
]
- remove_update_callback(listener: pxr.Tf.Listener = None) usdrt.Rt.ChangeTracker
Removes the update callback for changes.
- Parameters
listener (Optional[
pxr.Tf.Listener
]) – The listener to remove.- Returns
None, indicating the callback has been removed.
- Return type
usdrt.Rt.ChangeTracker
- remove_update_callback_ref_prim_maker(listener: pxr.Tf.Listener = None) usdrt.Rt.ChangeTracker
Removes the update callback reference to the prim maker.
- Parameters
listener (Optional[
pxr.Tf.Listener
]) – The listener to remove.- Returns
None, indicating the callback has been removed.
- Return type
usdrt.Rt.ChangeTracker
- set_stage()
Sets the USD stage.
- setup_update_callback() ChangeTracker
Sets up the update callback for changes.
- Returns
The change tracker instance.
- Return type
usdrt.Rt.ChangeTracker
- setup_update_callback_ref_prim_maker(func: Callable[[List, List[Union[Path, Path]], List[Union[Path, Path]], str], None]) ChangeTracker
Sets up the update callback with a reference to the prim maker function.
- Parameters
func (Callable) – The function to call when changes occur.
- Returns
The change tracker instance.
- Return type
usdrt.Rt.ChangeTracker
- to_pxr_path(path: Union[Path, Path]) Path
Converts a path to a pxr.Sdf.Path type.
- Parameters
path (Union[
usdrt.Sdf.Path
, pxr.Sdf.Path]) – The path to convert.- Returns
The converted pxr path.
- Return type
pxr.Sdf.Path
- update_changes()
Updates changes in the USD stage.
- update_xform_cache()
Updates the transform cache.
- xform_set_time()
Sets the time for the transform cache.
- property is_inited
Gets the initialization status of the FabricDataAccessor.
- Returns
The initialization status.
- Return type
bool
- property priority: int
Gets the priority value of the FabricDataAccessor.
- Returns
The priority value.
- Return type
int
- property priority_write: int
Gets the write priority value of the FabricDataAccessor.
- Returns
The write priority value.
- Return type
int
- property usd_context
Gets the USD context associated with the FabricDataAccessor.
- Returns
The USD context.
- Return type
omni.usd.UsdContext