I’ve been experimenting with the Python API in
usdview to dynamically create a
PointInstancer and set up a few instances. After setting up the
PointInstancer, I noticed that the instances aren’t immediately visible in the viewer. However, if I save the stage to a USD file and then reopen that file in
usdview, the instances render as expected.
Has anyone else experienced this issue? Is there a step or refresh command I might be missing to update the
usdview renderer immediately after making these changes?
Any insights or suggestions would be greatly appreciated!
Minimal code to recreate:
from pxr import Usd, UsdGeom, Gf # Get the current stage from usdview stage = usdviewApi.stage # Create a new PointInstancer at the root of the stage pointInstancer = UsdGeom.PointInstancer.Define(stage, '/myPointInstancer') # Create a new Sphere as the prototype for the PointInstancer sphereProto = UsdGeom.Sphere.Define(stage, '/myPointInstancer/sphereProto') # Set the prototypes relationship on the PointInstancer to point to the Sphere pointInstancer.GetPrototypesRel().AddTarget(sphereProto.GetPath()) # Set the positions for three instances of the sphere positions = [ Gf.Vec3f(0, 0, 0), Gf.Vec3f(2, 0, 0), Gf.Vec3f(4, 0, 0) ] pointInstancer.GetPositionsAttr().Set(positions) # Set the protoIndices for the three instances (all pointing to the single sphere prototype) protoIndices = [0, 0, 0] pointInstancer.GetProtoIndicesAttr().Set(protoIndices) # Edit/update # Required to render the PointInstancer after populating attributes stage.GetEditTarget()