OpenUSD Exchange Samples: createTransforms

November 6, 2025 ยท View on GitHub

This sample demonstrates how to open/create a stage with key metadata and apply transforms to prims using the OpenUSD Exchange SDK.

USD Modules

The Gf, Sdf, and Usd modules are used

OpenUSD Exchange SDK functions

  • createStage()
  • defineXform()
  • getLocalTransform()
  • getLocalTransformComponents()
  • getValidChildNames()
  • saveStage()
  • setLocalTransform()

Languages

This sample is implemented in both C++ and Python. To run:

  • [./]run.[bat, sh] createTransforms
  • python[3] source/python/createTransforms.py

Hardcoded items

  • If a stage is created, it has a default prim named "World", Y-up axis, 1 cm linear units
  • A prim (either found or created) is rotated 45 degrees in the prim's middle rotation axis
    • The prim is found using a method called stage traversal
    • If a xformable prim isn't found a cube will be created to rotate
    • Note that the typical rotation order is XYZ, so the expectation is that the sample rotates the prim on the Y axis
  • A Xform prim named "groundXform" is created and lowered 55 cm
  • A cube prim named "groundCube" is created as a child of "groundXform" with a scale of (20, 0.1, 20)
  • A cube prim named "quatCube" is created with a quaternion orientation

More resources

If you need to get the transform of a prim in world space (taking into account the transforms of ancestor prims), you can use either of these functions:

For the best performance when querying multiple transforms, the UsdGeomXformCache should be used. Note that the class does not automatically invalidate cached values based on changes to the stage from which values were cached. Additionally, a separate instance of this class should be used per-thread, calling the Get* methods from multiple threads is not safe, as they mutate internal state.

See Get the World Space Transforms for a Prim for examples.

Command Line Arguments

Usage:
  createTransforms [OPTION...]

  -a, --usda          Output a text stage rather than binary
  -h, --help          Print usage
  -p, --path arg      Alternate destination stage path (default: c:/Users/username/AppData/Local/Temp/usdex/sample.usdc)