Listen/Subscribe to selection changed events

Hello, I have been searching through the documentation on how to listen to selection events, I tried event stream and I tried the USD notification system (TfNotice) but with not luck. Basically I want to limit the user selection to a certain depth in the stage tree so I need to listen if the selection event and change the selection target accordingly.

Thank you.

For selection changes you would want to Stage Events for selection

import carb.events
import omni.usd


def on_stage_event(e: carb.events.IEvent):
	if e.type == int(omni.usd.StageEventType.SELECTION_CHANGED):
		print("selection changed")


stage_event_sub = (
	omni.usd.get_context()
	.get_stage_event_stream()
	.create_subscription_to_pop(on_stage_event, name="My Subscription Name")
)

Here’s a sample extension that utilizes the selection changed event: GitHub - NVIDIA-Omniverse/kit-extension-sample-ui-scene: Sample Repository to create Kit Extension using the ui.scene API

Great thank you.

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