How to query USD prim World Bounding Box

   2939   1   2
User Avatar
Member
55 posts
Joined: April 2019
Offline
A very simple question which seems to be tricky to figure out! All geom prims have a World Bounding Box shown in Solaris Scene Graph Details. How does one access that via Python and Vex?! I've tried the following, but I get inconsistent results that are not the same as what's shown in Scene Graph Details!

from pxr import Usd, UsdGeom

node = hou.pwd()
stage = node.editableStage()

prim = stage.GetPrimAtPath('/scene/geo/cube')
bbox_cache = UsdGeom.BBoxCache(0, ['default'])
bbox = bbox_cache.ComputeWorldBound(prim).box

print bbox
VFX Supervisor | CG Artist

http://yasinhasanian.com/ [yasinhasanian.com]
User Avatar
Member
2 posts
Joined: Aug. 2022
Offline
Very late reply but just ran into the same issue. This works:

from pxr import Usd, UsdGeom

node = hou.pwd()
stage = node.editableStage()

prim = stage.GetPrimAtPath('/scene/geo/cube')
bbox_cache = UsdGeom.BBoxCache(0, )
bbox = bbox_cache.ComputeWorldBound(prim)
bounds = bbox.ComputeAlignedBox()

print bounds
  • Quick Links