Payload Enable/Disable

Hi Everyone,

I’m working on an extension where I have a treeview generated from certain attributes of stage and the associated prim path.
I would like to update my treeview whenever the payload is enabled or disabled.
To achieve this, I prefer to have a listner event (similar to an ‘_on_stage_event’ of stage).
However, I’m unable to find any events associated with Payloads or find a solution on how to detect any changes in Payloads via stage events.

So it would be really helpful if you could give me suggesstions on how to tackle this issue. Thanking you in advance.

Did you find any solution. I’ve the same problem.
I tried to get the notifiaction for the payload which i haved click. But unfortunately, if I checked the payload checkbox in the stage, I got the prim path from the parent node. But if I uncheck the payload then I receive the right prim path. I found no solution right there.
Finally, I iterate over all stage payloads element and check it on my own if everything hast changed.

  1. Register Listener to receive notification if an object was changed. This include also the payload
    → Tf.Notice.Register(Usd.Notice.ObjectsChanged, self.update_payloads, None)

  2. Define the callback Method update_payloads
    def update_payloads(self,notice,sender):
    #get_payloads is my custom Method to iterate over the whole stage and extract only the payload
    #elements
    payload_prims = self.get_payloads()

         for prim_ref in payload_prims:                
             if self._model:
                 #this call my customized Method for doing the updates
                 self._model.update_payload(
                     prim_ref.GetName(),
                     prim_ref.IsLoaded())
    

Hi @Benutzer4638 and @anchana.ra.radhakrishnan. That is currently the right approach. I will add that you want to use GetResyncedPaths() to find that paths that were added or removed during the load/unload.

import omni.usd
from pxr import Sdf, Tf, Usd

def changed_paths(notice, stage):
    print("Change fired")
    for p in notice.GetResyncedPaths():
        if "/World/Xform" in str(p) and not str(p) == "/World/Xform":
            print(p)
            print("Something happened to Xform or its children")

objects_changed = Tf.Notice.Register(Usd.Notice.ObjectsChanged, changed_paths, None)
1 Like

I’ve created internal ticket OM-81499 requesting an easier way to do this.

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