Successive Omni kit commands need stage refresh? - Please help!

Hi there. I have an issue that I’ve narrowed down to the simple case below.
2 commands (recorded from the ui) to make a material prim and set a property on it. When run individually, these behave fine. When run together, the second one fails. I’m thinking there needs to be some kind of refresh (or pause) in order for the second command to find its newly created attribute target?
Apologies for the noob question - any suggestions appreciated!

omni.kit.commands.execute('CreateMdlMaterialPrimCommand', mtl_url='OmniSurface.mdl', mtl_name='OmniSurface', mtl_path= Sdf.Path('/World/Looks').AppendChild('blue_OmniSurface') )

omni.kit.commands.execute('ChangeProperty', prop_path=Sdf.Path('/World/Looks/blue_OmniSurface/Shader.inputs:diffuse_reflection_color'), value=Gf.Vec3f(0, 0.0, 1.0), prev=Gf.Vec3f(1.0, 1.0, 1.0))

Hi @oliver_shaw. Materials have their parameters created lazily. One solution is presented in our omni.usd docs. You can run it async and wait a couple of frames between creating the material, selecting it, and changing the property. USD in Kit — omni.kit.usd_docs 1.1.0 documentation

Many thanks mati!

1 Like