I am trying to modify many prims at once in the scene using USDRT. The issue I have is that, unless I call stage.WriteToStage
after applying the modifications, the scene does not get updated. From looking at the documentation and examples ( Working with OmniHydra Transforms — usdrt 4.0.5 documentation (omniverse-docs.s3-website-us-east-1.amazonaws.com)), it doesn’t seem to be necessary to call WriteToStage
for the scene to update.
I made an example with the following code:
from usdrt import Usd, UsdGeom, Gf, Rt, Vt, Sdf
stage = Usd.Stage.Attach(omni.usd.get_context().get_stage_id())
prim: Usd.Prim = stage.GetPrimAtPath(Sdf.Path("/World/Cube"))
if not prim.HasAttribute(UsdGeom.Tokens.primvarsDisplayColor):
prim.CreateAttribute(UsdGeom.Tokens.primvarsDisplayColor, Sdf.ValueTypeNames.Vector3fArray, False)
color = prim.GetAttribute(UsdGeom.Tokens.primvarsDisplayColor)
color.Set(Vt.Vec3fArray([Gf.Vec3f(0, 1, 0)]))
stage.WriteToStage() # Without this line, the cube's color does not change
Is WriteToStage
necessary? If not, what may I be doing wrong?