Tf.Notice.Register on Usd.Notice.ObjectsChanged events not firing when USD property changes are made to a live session

Tf.Notice.Register on Usd.Notice.ObjectsChanged events not firing when USD property changes are made to a live session.

here is how I setup the live session

async def initialize_async(stage_url):
    stage = Usd.Stage.Open(stage_url)
    live_session = LiveEditSession(stage_url)
    live_layer = await live_session.ensure_exists()
    session_layer = stage.GetSessionLayer()
    session_layer.subLayerPaths.append(live_layer.identifier)
    stage.SetEditTarget(live_layer)
    iot_root = live_layer.GetPrimAtPath("/iot")
    iot_spec = live_layer.GetPrimAtPath(f"/iot/data")
    if not iot_spec:
        iot_spec = Sdf.PrimSpec(iot_root, "data", Sdf.SpecifierDef, "IoTData")

    omni.client.live_process()

    return stage, live_layer, iot_spec

and here is how I register the listener

async def run(stage):
    async def on_objects_changed(notice, stage):
        print("USD Listener triggered!!")
        changed_attributes = notice.GetChangedAttributes()
        for path in changed_attributes:
            attr = stage.GetAttributeAtPath(path)
            if attr:
                print(f"Attribute changed: {attr.GetName()}, New value: {attr.Get()}")

    Tf.Notice.Register(Usd.Notice.ObjectsChanged, on_objects_changed, stage)
    print("USD Listener registered!!")

adding or modifying an attribute like /iot/data.testAttribute does not fire an event.

app.py.txt (2.5 KB)

Ok let me see if I can get you some help. You are writing this script yourself from scratch ? Why are you not using the standard LIVE workflow we have already set up ?

Curious on more details on mentioned live workflow but this script will part of a bidirectional connector to pickup changes to USD properties and publish to another system. Looks like there are other ways to subscribe to live layer changes but still unable to get this to work.

https://docs.omniverse.nvidia.com/kit/docs/client_library/latest/docs/python.html#omni.client.live_register_queued_callback

Please take a look at the examples we have on GitHub
connect-samples/source/pyHelloWorld/liveSession.py at main · NVIDIA-Omniverse/connect-samples · GitHub

iot-samples/exts/omni.iot.sample.panel/omni/iot/sample/panel/extension.py at 932b788ce7e1fcc1b75971d936ad23e3e576f54c · NVIDIA-Omniverse/iot-samples · GitHub

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.