Author Data for a Particular Variant

Opinions (i.e. data) for a particular variant can be authored on different layers. This shows how you can author opinions for an existing variant that might have been authored on a different layer.

shading_varset = prim.GetVariantSets().GetVariantSet("shading")
selected_variant = shading_varset.GetVariantSelection()

with shading_varset.GetVariantEditContext():
    # Specs authored within this context are authored just for the variant.

# Set the variant selection back to the previously selected variant.
# Alternatively, you can use Usd.VariantSet.ClearVariantSelection()
# if you know that there isn't a variant selection in the current EditTarget.
if selected_variant: