-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathRemoveVariantSet.py
More file actions
26 lines (21 loc) · 903 Bytes
/
RemoveVariantSet.py
File metadata and controls
26 lines (21 loc) · 903 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
import omni.usd
# Get stage.
stage = omni.usd.get_context().get_stage()
prim_path = "/World/Chair"
prim = stage.GetPrimAtPath(prim_path)
# "variantGroup" is the name of the VariantSet to be deleted.
variant_set_name = "variantGroup"
variant_sets = prim.GetVariantSets()
if variant_sets.HasVariantSet(variant_set_name):
# Clear variant selection.
variant_set = prim.GetVariantSet(variant_set_name)
variant_set.ClearVariantSelection()
# Deletes the specified variantSet, which must be passed via SdfPrimSpec.
stage = prim.GetStage()
prim_path = prim.GetPath()
for layer in stage.GetLayerStack():
prim_spec = layer.GetPrimAtPath(prim_path) # SdfPrimSpec
if prim_spec and variant_set_name in prim_spec.variantSets:
del prim_spec.variantSets[variant_set_name]
prim_spec.variantSetNameList.Remove(variant_set_name)