-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathGetVariant.py
More file actions
35 lines (27 loc) · 942 Bytes
/
GetVariant.py
File metadata and controls
35 lines (27 loc) · 942 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
27
28
29
30
31
32
33
34
35
from pxr import Usd
import omni.usd
def get_variant_info(prim: Usd.Prim):
"""
Get variant information of the specified prim.
"""
# Get variant sets name.
variantSets = prim.GetVariantSets()
print(f"variantSets: {variantSets.GetNames()}")
for variantSetName in variantSets.GetNames():
print(f"[{variantSetName}]")
# Get variant names.
variant_set = prim.GetVariantSet(variantSetName)
variant_names = variant_set.GetVariantNames()
print(f" variantNames: {variant_names}")
# Get current variant selection.
print(f" selection: {variant_set.GetVariantSelection()}")
# Get stage.
stage = omni.usd.get_context().get_stage()
# Get selection.
selection = omni.usd.get_context().get_selection()
paths = selection.get_selected_prim_paths()
for path in paths:
# Get prim.
prim = stage.GetPrimAtPath(path)
if prim:
get_variant_info(prim)