How to get Translate in world coordinate system

Hi @fm1930

A possible solution would be to calculate the transformation with respect to the world using the ComputeLocalToWorldTransform method as shown in the following snippet

import omni
from pxr import Usd, UsdGeom, Gf

stage = omni.usd.get_context().get_stage()
prim = stage.GetPrimAtPath("/World/ObjectA/ObjectB")

transform = Gf.Transform()
transform.SetMatrix(UsdGeom.Xformable(prim).ComputeLocalToWorldTransform(Usd.TimeCode.Default()))

position = transform.GetTranslation()
orientation = transform.GetRotation().GetQuat()

print(position)
print(orientation)
2 Likes