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 = '',
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. 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 “”.
Class Constants:
- VERSION: int = 3#
Version of the ClashQuery data structure.
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 with current date & time.
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.
- creation_timestamp: datetime#
Gets the creation timestamp.
- last_modified_timestamp: datetime#
Gets or sets the last modified timestamp. Setting this property updates the last modified by user to the current user.
- 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.
Example#
Creating and using a ClashQuery:
from omni.physxclashdetectioncore.clash_query import ClashQuery
from omni.physxclashdetectioncore.clash_detect_settings import SettingId
# Create a new 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)