Omni PhysX Commands
Physics commands are providing undo/redo capability for a list of utilities from omni.physx.utils and omni.physx.physicsUtils or are directly applying or removing APIs from the physics USD schemas in defined sets which we call ‘Components’ (see the schema documentation).
For a general overview of the command system (see Kit Commands documentation).
Utility Commands
- class omni.physxcommands.AddCollisionGroupCommand(stage, path)
Wrapper for omni.physx.utils.addCollisionGroup. Creates a UsdPhysics.CollisionGroup prim.
- Parameters
stage – USD stage.
path – Path of the primitive to be created at.
- class omni.physxcommands.AddGroundPlaneCommand(stage, planePath, axis, size, position, color)
Wrapper for omni.physx.physicsUtils.add_ground_plane. Adds a zero-thick plane to prevent physics-enabled prims from falling to infinity. Creates an UsdGeom.Xform with a UsdGeom.Mesh and a UsdGeom.Plane child primitives.
- Parameters
stage – USD stage.
planePath – Path for the root xform to be created at. Finds first free path.
axis – Up axis.
size – Halfsize of one side.
position – Center of the plane.
color – Display color.
- Returns
Path where the plane was actually created.
- class omni.physxcommands.AddPairFilterCommand(stage, primPaths)
Wrapper for omni.physx.utils.addPairFilter. Filters out collisions between primitives using UsdPhysics.FilteredPairsAPI.
- Parameters
stage – USD stage.
primPaths – List of paths.
- class omni.physxcommands.AddPhysicsSceneCommand(stage, path)
Wrapper for omni.physx.utils.addPhysicsScene. Adds a UsdPhysics.Scene prim with default params.
- Parameters
stage – USD stage.
path – Path of the primitive to be created at.
- class omni.physxcommands.CreateJointCommand(stage, joint_type, from_prim, to_prim)
Wrapper for omni.physx.utils.createJoint. Connects two primitives with a physical joints.
- Parameters
stage – Path of the target primitive.
joint_type – Fixed, Revolute, Prismatic, Spherical or Distance. If left blank a D6 Joint is used.
from_prim – From primitive.
to_prim – To primitive.
- Returns
Joint primitive.
- class omni.physxcommands.CreateJointsCommand(stage, joint_type, paths, join_to_parent=False)
Wrapper for omni.physx.utils.createJoints. Connects a list of primitives with their parent or a pseudo-root with physical joints.
- Parameters
stage – Path of the target primitive.
joint_type – Fixed, Revolute, Prismatic, Spherical or Distance. If left blank a D6 Joint is used.
paths – A list of paths.
join_to_parent – Connect primitives to their parents if True, otherwise to a scene pseudo-root.
- Returns
Joint primitives.
- class omni.physxcommands.RemovePairFilterCommand(stage, primPaths)
Wrapper for omni.physx.utils.removePairFilter. Removes UsdPhysics.FilteredPairsAPI from primitives.
- Parameters
stage – USD stage.
primPaths – List of paths.
- class omni.physxcommands.RemoveRigidBodyCommand(path)
Wrapper for omni.physx.utils.removeRigidBody.
- Parameters
path – Path of the target primitive.
- class omni.physxcommands.RemoveStaticColliderCommand(path)
Wrapper for omni.physx.utils.removeStaticCollider.
- Parameters
path – Path of the target primitive.
- class omni.physxcommands.SetRigidBodyCommand(path, approximationShape='convexHull', kinematic=False)
Wrapper for omni.physx.utils.setRigidBody. Applies UsdPhysics.RigidBodyAPI and a UsdPhysics.CollisionAPI to target prim. Applies UsdPhysics.MeshCollisionAPI if it’s a mesh. Collision API’s are also applied to the whole subtree if the target prim is an xform.
- Parameters
path – Path of the target primitive.
approximationShape – Physics param.
kinematic – Physics param.
- class omni.physxcommands.SetStaticColliderCommand(path, approximationShape='none')
Wrapper for omni.physx.utils.setStaticCollider. Applies Collision APIs (UsdPhysics.CollisionAPI, UsdPhysics.MeshCollisionAPI) to a target prim and its subtree.
- Parameters
path – Path of the target primitive.
approximationShape – Physics param.
Helper Commands
- class omni.physxcommands.ApplyAPISchemaCommand(api, prim, api_prefix=None, multiple_api_token=None)
Undoable Apply API command.
- Parameters
api – API class.
prim – Target primitive.
api_prefix – Prefix of a multiple-apply API.
multiple_api_token – Token of a multiple-apply API.
- class omni.physxcommands.ChangeAttributeCommand(attr: pxr.Usd.Attribute, widget: Any, value: Any, prev: Any)
Change prim property undoable Command.
- Parameters
attr (attribute) – Attribute to change.
value – Value to change to.
value – Value to undo to.
- class omni.physxcommands.PhysicsCommand
Base class for physics commands. Adds an execute helper to not force the user to use only keyword arguments
- class omni.physxcommands.RemoveAttributeCommand(attribute, prim)
- class omni.physxcommands.RemoveRelationshipCommand(relationship, prim)
- class omni.physxcommands.UnapplyAPISchemaCommand(api, prim, api_prefix=None, multiple_api_token=None)
Undoable Unapply API command.
- Parameters
api – API class.
prim – Target primitive.
api_prefix – Prefix of a multiple-apply API.
multiple_api_token – Token of a multiple-apply API.
Component Commands
- class omni.physxcommands.AddPhysicsComponentCommand(usd_prim: pxr.Usd.Prim, component: str, multiple_api_token: Optional[str] = None)
Add physics component command. See omni.physx.commands source for currently valid component names.
- Parameters
usd_prim – USD prim to apply a component to.
str – Component name.
multiple_api_token – Component instance name (if applicable).
- class omni.physxcommands.RemovePhysicsComponentCommand(usd_prim: pxr.Usd.Prim, component: str, multiple_api_token: Optional[str] = None)
Remove physics component. See omni.physx.commands source for currently valid components.
- Parameters
usd_prim – USD prim to apply a component to.
str – Component name.
multiple_api_token – Component instance name (if applicable).
For a list of low-level component commands called through AddPhysicsComponentCommand and RemovePhysicsComponentCommand see below:
- class omni.physxcommands.AddD6PhysicsJointComponentCommand(usd_prim: pxr.Usd.Prim, component: str)
- class omni.physxcommands.AddDistancePhysicsJointComponentCommand(usd_prim: pxr.Usd.Prim, component: str)
- class omni.physxcommands.AddFixedPhysicsJointComponentCommand(usd_prim: pxr.Usd.Prim, component: str)
- class omni.physxcommands.AddPrismaticPhysicsJointComponentCommand(usd_prim: pxr.Usd.Prim, component: str)
- class omni.physxcommands.AddRevolutePhysicsJointComponentCommand(usd_prim: pxr.Usd.Prim, component: str)
- class omni.physxcommands.AddSphericalPhysicsJointComponentCommand(usd_prim: pxr.Usd.Prim, component: str)
- class omni.physxcommands.RemoveD6PhysicsJointComponentCommand(usd_prim: pxr.Usd.Prim, component: str)
- class omni.physxcommands.RemoveDistancePhysicsJointComponentCommand(usd_prim: pxr.Usd.Prim, component: str)
- class omni.physxcommands.RemoveFixedPhysicsJointComponentCommand(usd_prim: pxr.Usd.Prim, component: str)
- class omni.physxcommands.RemovePrismaticPhysicsJointComponentCommand(usd_prim: pxr.Usd.Prim, component: str)
- class omni.physxcommands.RemoveRevolutePhysicsJointComponentCommand(usd_prim: pxr.Usd.Prim, component: str)
- class omni.physxcommands.RemoveSphericalPhysicsJointComponentCommand(usd_prim: pxr.Usd.Prim, component: str)