I am writing an Omniverse Extension. Part of the UI is a dropdown box with all of the stage’s Xforms. I want the contents of the dropdown box to be updated any time an Xform is added or deleted in the scene. I tried with subscribing to stage events but unfortunately it seems there is no event when an Xform is added, only if it is deleted.
How can my code be notified properly about Xform added or deleted?
How can I update the model’s items accordingly? I use isaac’s dropdown_builder to create it.
You might consider basing your extension off of the Stage extension since it accurately tracks changes to Xforms.
Stage uses isaac-sim/kit/extscore/omni.usd/omni/usd/_impl/utils.py, which gets changes and updates the cache (including deletion) for usd property changes, and creates the listener for changes. If possible I would interface this module rather than borrowing code from it.
The Stage extension also can apply updates to models, and the code to do so should live in either the omni.usdpackage path, the omni.kit.widget.stage package path, or the omni.kit.stage_column package path.
def _on_objects_changed(self, notice, sender):
paths = notice.GetResyncedPaths()
prim_path = False
for path in paths:
if path.IsPrimPath():
prim_path = True
break
if not prim_path:
return
self._update_bt_model()
Now I can react on any prim changes, which is ok for the moment.
Kind regards
Bruno