clash_query#
This module provides the ClashQuery class for managing clash detection query parameters.
Classes#
ClashQuery#
- class omni.physxclashdetectioncore.clash_query.ClashQuery(
- identifier: int = -1,
- query_name: str = '',
- object_a_path: str = '',
- object_b_path: str = '',
- clash_detect_settings: Dict[str, Any] | None = None,
- creation_timestamp: datetime | None = None,
- last_modified_timestamp: datetime | None = None,
- last_modified_by: str = '',
- comment: str = '',
- roi_include_path: str = '',
- roi_exclude_path: str = '',
A class for managing and executing clash detection queries.
A class that is designed to manage settings for clash detection queries. It includes functionality to serialize and deserialize settings, manage query metadata and update timestamps.
- Parameters:
identifier (int) – Unique identifier for the clash query. -1 means not yet assigned / uninitialized. Defaults to -1.
query_name (str) – Name of the clash query. Defaults to “”.
object_a_path (str) – Path to the first object involved in the clash detection. Can contain multiple paths separated by space/tab/newline. When
SETTING_ENABLE_POINT_CLOUDS=True, this contains point cloud prim path(s); otherwise mesh path(s). Defaults to “”.object_b_path (str) – Path to the second object involved in the clash detection. Can contain multiple paths separated by space/tab/newline. Defaults to “”.
clash_detect_settings (Optional[Dict[str, Any]]) – Settings for the clash detection process. Defaults to None.
creation_timestamp (Optional[datetime]) – Timestamp when the query was created. Defaults to None (current time).
last_modified_timestamp (Optional[datetime]) – Timestamp when the query was last modified. Defaults to None (current time).
last_modified_by (str) – Name of the user who last modified the query. Defaults to “” (current user).
comment (str) – Additional comments or notes about the query. Defaults to “”.
roi_include_path (str) – ROI (Region of Interest) include paths separated by space/tab/newline. Used when
SETTING_ENABLE_POINT_CLOUDS=Trueto filter which regions of a point cloud are included in clash detection. Defaults to “”.roi_exclude_path (str) – ROI (Region of Interest) exclude paths separated by space/tab/newline. Used when
SETTING_ENABLE_POINT_CLOUDS=Trueto filter which regions of a point cloud are excluded from clash detection. Defaults to “”.
Class Constants:
- VERSION: int = 5#
SQLite table schema version. Read by
ClashDataSerializerSqliteto validate and migrate saved data.
Methods:
- serialize_to_dict() Dict[str, Any]#
Converts the ClashQuery instance to a dictionary in JSON-serializable format.
- Returns:
Dictionary containing the serialized ClashQuery data.
- Return type:
Dict[str, Any]
- classmethod deserialize_from_dict(
- data: Dict[str, Any],
- reset_identifier: bool = False,
Deserializes a ClashQuery instance from a JSON-serializable dictionary format.
- Parameters:
data (Dict[str, Any]) – Dictionary containing serialized ClashQuery data.
reset_identifier (bool) – If True, resets the identifier to -1 after deserialization. Defaults to False.
- Returns:
New ClashQuery instance if deserialization succeeds, None if it fails.
- Return type:
ClashQuery | None
- load_settings_from_str(settings_str: str) bool#
Deserializes settings values from the json string.
- Parameters:
settings_str (str) – The JSON string containing settings.
- Returns:
True on success, otherwise False.
- Return type:
bool
- get_settings_as_str() str#
Serializes setting values to the json string and returns the string.
- Returns:
The JSON string representation of settings.
- Return type:
str
- update_last_modified_timestamp() None#
Updates last modified timestamp and user with current date & time and the current user.
- reset_identifier() None#
Resets the identifier to -1 (unassigned). Used after deserialization when a fresh identity is needed.
Properties:
- identifier: int#
Read-only property that returns the unique identifier of the query.
- query_name: str#
Gets or sets the query name. Setting this property updates the last modified timestamp.
- object_a_path: str#
Gets or sets the object A path. Can contain multiple paths separated by space/tab/newline. Setting this property updates the last modified timestamp.
- object_b_path: str#
Gets or sets the object B path. Can contain multiple paths separated by space/tab/newline. Setting this property updates the last modified timestamp.
- clash_detect_settings: Dict[str, Any]#
Gets or sets the clash detect settings. Setting this property updates the last modified timestamp.
Note
Direct modifications made to the returned dictionary do not update the last modified timestamp. Assign a new dictionary to this property to trigger a timestamp update.
- creation_timestamp: datetime#
Gets the creation timestamp.
- last_modified_timestamp: datetime#
Gets or sets the last modified timestamp.
Note
Setting this property intentionally does not update
last_modified_by- it is used when loading from storage where preserving the original author is desired.
- last_modified_by: str#
Read-only property that returns the name of the user who last modified the query.
- comment: str#
Gets or sets the comment. Setting this property updates the last modified timestamp.
- roi_include_path: str#
Gets or sets the ROI (Region of Interest) include paths separated by space/tab/newline. Used when
SETTING_ENABLE_POINT_CLOUDS=Trueto restrict point cloud clash detection to specific spatial regions. Setting this property updates the last modified timestamp.
- roi_exclude_path: str#
Gets or sets the ROI (Region of Interest) exclude paths separated by space/tab/newline. Used when
SETTING_ENABLE_POINT_CLOUDS=Trueto exclude specific spatial regions from point cloud clash detection. Setting this property updates the last modified timestamp.
Example#
Creating and using a ClashQuery for standard mesh-mesh detection:
from omni.physxclashdetectioncore.clash_query import ClashQuery
from omni.physxclashdetectioncore.clash_detect_settings import SettingId
# Create a new mesh-mesh clash query
query = ClashQuery(
query_name="Full Scene Hard Clash Detection",
object_a_path="", # Empty means full scene
object_b_path="", # Empty means full scene
clash_detect_settings={
SettingId.SETTING_TOLERANCE.name: 0.0, # Hard clashes
SettingId.SETTING_DYNAMIC.name: False, # Static detection
SettingId.SETTING_LOGGING.name: True
},
comment="Initial clash detection for the project"
)
# Serialize to dictionary
query_dict = query.serialize_to_dict()
# Deserialize from dictionary
restored_query = ClashQuery.deserialize_from_dict(query_dict)
Creating a point cloud vs mesh ClashQuery:
from omni.physxclashdetectioncore.clash_query import ClashQuery
from omni.physxclashdetectioncore.clash_detect_settings import SettingId
# Create a point cloud vs mesh clash query
# object_a_path holds the point cloud prim path(s) when SETTING_ENABLE_POINT_CLOUDS is True
# object_b_path holds the mesh prim path(s) to test against
pc_query = ClashQuery(
query_name="Point Cloud vs Mesh Clash Detection",
object_a_path="/World/PointCloud", # point cloud source prim
object_b_path="/World/Building", # mesh geometry to test against
clash_detect_settings={
SettingId.SETTING_ENABLE_POINT_CLOUDS.name: True,
SettingId.SETTING_POINT_SIZE_OVERRIDE.name: 0.0, # auto-compute point size
SettingId.SETTING_LOGGING.name: True,
},
roi_include_path="/World/ROI/Include", # only points inside this volume are tested
roi_exclude_path="/World/ROI/Exclude", # points inside this volume are ignored
comment="Scan-to-BIM clash detection"
)