Skip to content

Instantly share code, notes, and snippets.

@spatial-bit
Created January 13, 2022 19:19
Show Gist options
  • Save spatial-bit/01ff05fd6e32bbe7a02347b752441c4a to your computer and use it in GitHub Desktop.
Save spatial-bit/01ff05fd6e32bbe7a02347b752441c4a to your computer and use it in GitHub Desktop.
USD procedural variants #USD #OMNIVERSE
# procedural variants
import omni.usd as _usd
stage = _usd.get_context().get_stage()
rootPrim = stage.GetPrimAtPath('/base_stage')
#rootPrim = stage.GetPseudoRoot()
vset = rootPrim.GetVariantSets()
print(vset.GetNames())
variant_set_name = 'materialVariant'
print(f'Has variant set: {vset.HasVariantSet(variant_set_name)}')
print(f'Variant selection: {vset.GetVariantSelection(variant_set_name)}')
vset.SetSelection(variant_set_name, 'MDL')
print(f'Variant selection: {vset.GetVariantSelection(variant_set_name)}')
vset.SetSelection(variant_set_name, 'ARNOLD')
print(f'Variant selection: {vset.GetVariantSelection(variant_set_name)}')
#vset.GetVariantSelection(variant_set_name)
#vset.SetSelection(variant_set_name, variant_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment