-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathEventSelection.py
More file actions
26 lines (21 loc) · 900 Bytes
/
Copy pathEventSelection.py
File metadata and controls
26 lines (21 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from pxr import Usd, UsdGeom, UsdPhysics, UsdShade, Sdf, Gf, Tf
# Get context.
context = omni.usd.get_context()
# Get stage.
stage = context.get_stage()
# ---------------------------------------------.
# Selected event.
# ---------------------------------------------.
def onStageEvent(evt):
if evt.type == int(omni.usd.StageEventType.SELECTION_CHANGED):
# Get selection paths.
selection = omni.usd.get_context().get_selection()
paths = selection.get_selected_prim_paths()
for path in paths:
prim = stage.GetPrimAtPath(path)
if prim.IsValid():
print(f"Selected [ {prim.GetName()} ]")
# ------------------------------------------------.
# Register for stage events.
# Specify "subs=None" to end the event.
subs = context.get_stage_event_stream().create_subscription_to_pop(onStageEvent, name="sampleStageEvent")