Clash Detect Layer Helper Utils#
Overview#
File Name: clash_detect_layer_utils.py
This file provides a set of utilities for managing clash detection layers within a USD stage. It includes functionalities for creating, removing, reloading, and manipulating these layers.
ClashDetectLayerHelper Class#
- class ClashDetectLayerHelper#
Static class with clash detection layer helper methods. This class provides methods for creating, removing, reloading, and managing clash detection layers within a USD stage.
Constants#
- CLASH_DETECT_FORMAT#
The file format for clash detection layers. Its value is “clashDetection”.
- CLASH_DETECT_LAYER_PREFIX#
The prefix for clash detection layer identifiers. Its value is “clashdata:”.
- CLASH_LAYER_IDENTIFIER#
The full identifier for clash detection layers. Its value is “{CLASH_DETECT_LAYER_PREFIX}{CLASH_DETECT_FORMAT}”.
Methods#
- create_new_clash_detect_layer(
- stage: Usd.Stage,
- layer_path_name: str,
Creates a new clash detection layer.
- Parameters:
stage (Usd.Stage) – The USD stage to which the layer is added.
layer_path_name (str) – The path name for the new layer.
- Returns:
The created clash detection layer, or None on failure.
- Return type:
Optional[Sdf.Layer]
- get_sublayer_position_in_parent(
- parent_layer_identifier: str,
- layer_identifier: str,
Returns the position of a sublayer within its parent layer.
- Parameters:
parent_layer_identifier (str) – The identifier of the parent layer.
layer_identifier (str) – The identifier of the sublayer.
- Returns:
Position of the sublayer, or -1 if not found.
- Return type:
int
- remove_sublayer(layer: Sdf.Layer, position: int) str | None #
Removes a sublayer from a specified position.
- Parameters:
layer (Sdf.Layer) – The layer from which to remove the sublayer.
position (int) – The position of the sublayer to remove.
- Returns:
Identifier of the removed sublayer, or None if removal failed.
- Return type:
Optional[str]
- remove_layer(root_layer: Sdf.Layer, layer_identifier: str) bool #
Removes a layer identified by layer_identifier from the root layer.
- Parameters:
root_layer (Sdf.Layer) – The root layer from which to remove the layer.
layer_identifier (str) – The identifier of the layer to remove.
- Returns:
True if the layer was removed, False otherwise.
- Return type:
bool
- reload_layer(layer: Sdf.Layer) bool #
Reloads the specified layer.
- Parameters:
layer (Sdf.Layer) – The layer to reload.
- Returns:
True if the layer was successfully reloaded, False otherwise.
- Return type:
bool
- find_clash_detect_layer(layer_path_name: str) Sdf.Layer | None #
Returns the clash detection layer identified by path.
- Parameters:
layer_path_name (str) – The path name of the clash detection layer.
- Returns:
The found clash detection layer, or None if not found.
- Return type:
Optional[Sdf.Layer]
- get_custom_layer_data(layer) Dict[Any, Any] | None #
Returns custom data of a layer as a dictionary.
- Parameters:
layer (Sdf.Layer) – The layer from which to get custom data.
- Returns:
The custom data of the layer, or None if not found.
- Return type:
Optional[Dict[Any, Any]]
- set_custom_layer_data(
- layer: Sdf.Layer,
- d: Dict[Any, Any] | None,
Sets custom data for a layer using a dictionary.
- Parameters:
layer (Sdf.Layer) – The layer for which to set custom data.
d (Optional[Dict[Any, Any]]) – The custom data to set.
- kit_remove_layer(stage: Usd.Stage, layer_identifier: str) bool #
Removes a layer using a Kit command, ensuring the Layer Widget is aware.
- Parameters:
stage (Usd.Stage) – The USD stage from which to remove the layer.
layer_identifier (str) – The identifier of the layer to remove.
- Returns:
True if the layer was successfully removed, False otherwise.
- Return type:
bool