Stage getting prim "Local to World Transform" with Python

   2125   3   0
User Avatar
Member
21 posts
Joined: 3月 2019
Offline
Hi!

Does anyone have a python code snippet getting rotation value of "Local to World Transform" visible in violet color in Scene Graph Details?


Any help would be greatly appreciated
User Avatar
Member
38 posts
Joined: 9月 2014
Offline
I recommend this example from nvidia; https://docs.omniverse.nvidia.com/dev-guide/latest/programmer_ref/usd/transforms/get-world-transforms.html [docs.omniverse.nvidia.com]

You need to get an xformable object, then you can get the 'ComputeLocalToWorldTransform(time)' method. This example will also show you what else you can pull out of the xformable.

Cheers
Kym.
User Avatar
Member
21 posts
Joined: 3月 2019
Offline
Thanks for the link Kym!

I tried that snippet and got correct translation value but rotation retrieved with:
rotation: Gf.Rotation = world_transform.ExtractRotation()
gives me 3 axis and an angle but I am having hard time converting it to euler rotation that values would match those from Scene Graph Details. I tried Decompose() function but it was throwing an error. Probably doing something silly there.
Any hints how should I approach that?

Cheers!
Dawid
User Avatar
Member
1 posts
Joined: 3月 2015
Offline
I apologise for reviving an old thread, but I'm in a similar situation.
I need to be able to read the "local to world transforms" from several usdprims, and transfer those values to another set of prims via python without going through sops.
I tried using the snippet from the nvidia docs (
Xformable_API.ComputeLocalToWorldTransform(time)
), but the resulting transforms don't seem to match what houdini displays in the calculated (purple) attributes. Scale is messed up, specially with prims with negative values.
Any ideas?
  • Quick Links