commands#
This module provides Omni Kit commands for clash detection operations.
Commands#
OpenStageForClashDetectionCommand#
- class omni.physxclashdetectioncore.commands.OpenStageForClashDetectionCommand(**kwargs)#
A command to open a USD stage for clash detection.
This command facilitates opening a USD stage and preparing it for clash detection processes. It ensures that the stage path is standardized and that the stage is correctly loaded into the cache.
Keyword Args:
- Parameters:
path (str) – The path to the USD stage.
stage_path (str) – An alternative key for the path to the USD stage.
Methods:
- do() int#
Opens the stage for clash detection.
- Returns:
The ID of the loaded stage.
- Return type:
int
- undo() None#
Undoes the clash detection stage opening.
SaveClashDetectionCommand#
- class omni.physxclashdetectioncore.commands.SaveClashDetectionCommand(stage_id)#
A command to save the results of a clash detection process.
This class provides the functionality to save the clash detection results for a given stage ID to a persistent storage.
- Parameters:
stage_id (int) – The ID of the stage for which the clash detection results are to be saved.
Methods:
- do() int#
Executes the command to save clash detection results.
- Returns:
The stage ID if successful, otherwise 0.
- Return type:
int
CloseStageForClashDetectionCommand#
- class omni.physxclashdetectioncore.commands.CloseStageForClashDetectionCommand(stage_id)#
A command to close a stage used for clash detection.
This command handles the process of closing a stage by erasing it from the stage cache and destroying any associated clash data.
- Parameters:
stage_id (int) – The identifier of the stage to be closed.
Methods:
- do() bool#
Closes the stage and cleans up clash detection data.
- Returns:
True if the stage was successfully closed, otherwise False.
- Return type:
bool
RunClashDetectionCommand#
- class omni.physxclashdetectioncore.commands.RunClashDetectionCommand(
- stage_id: int,
- object_a_path: str = '',
- object_b_path: str = '',
- tolerance: float = 0.0,
- dynamic: bool = False,
- start_time: float = 0.0,
- end_time: float = 0.0,
- logging: bool = False,
- html_path_name: str = '',
- json_path_name: str = '',
- query_name: str = 'RunClashDetectionCommand Query',
- comment: str = '',
Run the clash detection on a stage.
- Parameters:
stage_id (int) – ID of the stage to be processed.
object_a_path (str) – Absolute stage path or a USD collection to define searchset A. Defaults to “”.
object_b_path (str) – Absolute stage path or a USD collection to define searchset B. Defaults to “”.
tolerance (float) – Tolerance distance for overlap queries. Use zero for hard clashes, non-zero for soft (clearance) clashes. Defaults to 0.0.
dynamic (bool) – True for dynamic clash detection, False for static. Defaults to False.
start_time (float) – Start time in seconds. Only works when dynamic clash detection is enabled. Defaults to 0.0.
end_time (float) – End time in seconds. Only works when dynamic clash detection is enabled. Defaults to 0.0.
logging (bool) – If True, logs info & performance results to console. Defaults to False.
html_path_name (str) – Full path to HTML file if export to HTML is needed. No clash images will be exported. Defaults to “”.
json_path_name (str) – Full path to JSON file if export to JSON is needed. No clash images will be exported. Defaults to “”.
query_name (str) – Custom name for the clash detection query which will be generated based on parameters above. Defaults to “RunClashDetectionCommand Query”.
comment (str) – Custom comment for the clash detection query which will be generated based on parameters above. Defaults to “”.
Methods:
- do() int#
Executes the clash detection command.
- Returns:
ID of the stage processed.
- Return type:
int
- undo() bool#
Undoes the clash detection command.
- Returns:
True on success, otherwise False.
- Return type:
bool
Functions#
- omni.physxclashdetectioncore.commands.register_commands()#
Register all commands in the current module.
- omni.physxclashdetectioncore.commands.unregister_commands()#
Unregister all commands previously registered in the current module.
Example#
Running clash detection using commands:
import omni.kit.commands
from omni.physxclashdetectioncore import commands
# Register commands
commands.register_commands()
# Open stage
stage_id = omni.kit.commands.execute(
"OpenStageForClashDetectionCommand",
path="/path/to/stage.usd"
)
# Run clash detection
omni.kit.commands.execute(
"RunClashDetectionCommand",
stage_id=stage_id,
object_a_path="",
object_b_path="",
tolerance=0.0,
dynamic=False,
logging=True,
html_path_name="/path/to/output.html",
query_name="My Clash Detection"
)
# Save results
omni.kit.commands.execute(
"SaveClashDetectionCommand",
stage_id=stage_id
)
# Close stage
omni.kit.commands.execute(
"CloseStageForClashDetectionCommand",
stage_id=stage_id
)
# Unregister commands when done
commands.unregister_commands()