Hi,
I’m scripting generating a .usda file. How do I remove or avoid adding prepend variantSets = “selection” into the round brackets?
This is what I get: (I don’t want anything added into the round brackets and the script below adds the prepend variantSets as in the rectangle)
…with this code:
enviro_layer = Sdf.Layer.FindOrOpen(f'{save_directory}/enviro.usda')
if enviro_layer:
self.root_layer.subLayerPaths.append(enviro_layer.identifier)
enviro_prim = self.stage_pxr.OverridePrim("/enviro")
enviro_variant_set = enviro_prim.GetVariantSets().GetVariantSet("selection")
with Usd.EditContext(self.stage_pxr, self.root_layer):
enviro_variant_set.AddVariant('Ground')
enviro_variant_set.SetVariantSelection('Ground')
with enviro_variant_set.GetVariantEditContext():
enviro_prim.GetReferences().AddReference(assetPath="", primPath="/ground")
enviro_variant_set.ClearVariantSelection()
# 1 I'VE TRIED THIS
del enviro_prim.variantSets["selection"] # removes everything from { } brackets of over "enviro" while leaving the ( ) brackets as is, which is the opposite of what I'm trying to achieve
# 2 AND THIS
sel = self.stage_pxr.GetPrimAtPath("/enviro").GetVariantSets().GetVariantSet("selection")
del sel # doesn't remove anything
self.root_layer.subLayerPaths.remove(enviro_layer.identifier)
self.stage_pxr.GetRootLayer().Save()