Tips & Useful Links
Stage Manipulation and Frames of Reference
Reparenting assets
You can change how reparenting behaves under Edit > Preferences, and on the Stage Panel, scroll down to authoring. The Checkbox “Keep Prim world Transform when reparenting” lets you decide when reparenting if the objects remain in place or if they get moved to the parent’s frame of reference. You can use this to your advantage to apply offsets or change the parent’s origin without impacting the children elements.
Physics
The Physics properties of assets are all well-defined using Physics Schemas and Physx Schemas . The documentation of Physics properties and how to access them in code is defined in C++, but you can follow these guidelines to find the equivalent calls in python. The general usage will look like this (using generic names to represent an arbitrary API):
from pxr import Usd, UsdGeom, UsdPhysics, PhysxSchema
import omni.usd
stage = omni.usd.get_context().get_stage()
prim = stage.GetPrimAtPath("/Path/To/Prim")
physics_api_prim = UsdPhysics.SomePhysicsAPI(prim)
physx_api_prim = PhysxSchema.AnotherPhysxAPI(prim)
# Check if the API is Applied, if not, Apply it.
if not physics_api_prim:
physics_api_prim = UsdPhysics.SomePhysicsAPI.Apply(prim)
physics_attr = physics_api_prim.GetSomePhysicsAttr()
physx_attr = physx_api_prim.GetPhysxAttr()
# Check if Attribute is authored, otherwise create it
if not physics_attr:
physics_attr = physics_api_prim.CreateSomePhysicsAttr(1.0)
print(physics_attr.Get())
physics_attr.Set(10.0)
In some cases, you may need to have additional parameters when casting the Prim to a given API, for example Joint Drive and Joint State do require the joint type (“Prismatic”, or “Angular”, for instance). In these cases the C++ signature will contain a “TfToken” type. Replace it with a basic string and it should work in Python.
If you need to know the attribute name of some physics attribute you see on the UI, Hover over the attribute in the properties panel, and it will show its name in the tooltip. The attribute name standard is schema_name:attribute_name
, so for example something like physics:velocity
on a rigid body means it’s using the Physics Rigid Body API and the attribute name is velocity
, so the corresponding attribute getter would be UsdPhysics.RigidBodyAPI(prim).GetVelocityAttr()
.
Commands
You can run many of the UI commands through omni.kit.commands.execute("CommandName", args)
. To find a list of available commands, and what args to use, open Window > Commands, then click on Search Commands
. On the window that appears, you will find an extensive list of all the commands available, and their respective documentation. Each command comes from a source Extension, and enabling/disabling extensions will change the list of available commands.
Loading stages faster with Omniverse Cache
The first time you load a large stage, it may take a while for the materials to compile. Installing Omniverse Cache will help load the stage more quickly each subsequent time.
See the Workstation Installation for how to install