Subscribing to the Stage chagnes

Hello All,

Did anyone successfully manage to subscribe to the stage changes in a custom Omniverse extension?
Something similar to how Property widget updates on Prim selection change in the viewport or the Stage Widget. I tried digging into the Property window extension but with no luck so far!!!

Regards
Tanay Dimri

Hello @tanay-epigraph ,

you can subscribe to the stage event stream like this:

import omni.usd

def on_stage_event(event):
    if event.type in [int(omni.usd.StageEventType.OPENED), int(omni.usd.StageEventType.SAVED)]:
        print("stage event")

event_stream = omni.usd.get_context().get_stage_event_stream()
stage_event_sub = event_stream.create_subscription_to_pop(on_stage_event)

If you do this in you custom extension’s class, use self.stage_event_sub = … to keep the subscription alive during the lifetime of your extension.

1 Like

Thank you @mmontebaur !!
Will give this a try today.