Clash Data#

Overview#

File Name: clash_data.py

This file provides functionality for handling clash detection data within a USD stage.

It manages the creation, modification, and deletion of clash detection data layers and interfaces with a supplied serializer to handle the persistence of clash data and ensures compatibility and integrity of the data structures.

Functions#

serializer_data_op(fnc: function) function#

Decorator to identify serializer data operation.

Parameters:

fnc (function) – The function to be registered as a serializer data operation.

Returns:

The registered function.

Return type:

function

Classes#

ClashData Class#

class ClashData#

A class for handling clash detection data within a USD stage. This class manages the creation, modification, and deletion of clash detection data layers in a USD stage. It interfaces with a supplied serializer to handle the persistence of clash data and ensures compatibility and integrity of the data structures.

Constants#

CLASH_DATA_LAYER_FILE_EXT#

File extension for clash detection layer files. Its value is “.clashDetection”.

CLASH_DATA_FILE_EXT#

File extension for clash data files. Its value is “.clashdata”.

CLASH_DATA_LAYER_CUSTOM_CLASH_DB_PATH#

Key for custom clash database path in layer metadata. Its value is “clashDbPath”.

CLASH_DATA_LAYER_CUSTOM_MODIFIED#

Key indicating if the clash data layer has been modified. Its value is “clashDbModified”.

Constructor#

__init__(clash_data_serializer: AbstractClashDataSerializer)

Initializes a new instance of the ClashData class.

Parameters:

clash_data_serializer (AbstractClashDataSerializer) – An instance of AbstractClashDataSerializer implementation used for serializing clash data.

Methods#

destroy() None

Cleans up resources and resets object state.

open(
stage_id: int | None,
force_reload_layer: bool = False,
) None#

Creates a file or opens an existing one.

Parameters:
  • stage_id (Optional[int]) – Stage ID of the stage to work with.

  • force_reload_layer (bool) – Force reload target layer to ensure it doesn’t come from the cache.

is_open() bool#

Checks if the serializer is ready.

Returns:

True if the serializer is ready.

Return type:

bool

save() bool#

Saves data to the target file.

Returns:

True if save operation was successful.

Return type:

bool

save_as(usd_file_path: str) bool#

Saves data to a new target file.

Parameters:

usd_file_path (str) – The new file path to save to.

Returns:

Boolean indicating success or failure.

Return type:

bool

saved() None#

Performs operations after save.

close() None#

Closes opened file.

commit() None#

Writes any unwritten data to file.

Properties#

stage_id: int | None#

Read-only property that returns the associated stage ID.

It is set by the open() method.

stage: Usd.Stage | None#

Read-only property that returns the associated USD stage.

It is set by the open() method.

usd_file_path: str#

Read-only property that returns the file path of the USD stage.

serializer_path: str#

Read-only property that returns the file path used by the serializer.

data_structures_compatible: bool

Read-only property that returns True if the serializer has no compatibility issues (data structures, tables).

deferred_file_creation_until_first_write_op: bool

Bool property that indicates whether the serializer will postpone file creation until the first write operation is requested.

The class also implements serializer data operations by calling appropriate methods on provided serializer.