This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
UsdVariantSet Class Reference

A UsdVariantSet represents a single VariantSet in USD (e.g. More...

#include <variantSets.h>

Public Member Functions

USD_API bool AddVariant (const std::string &variantName, UsdListPosition position=UsdListPositionBackOfPrependList)
 Author a variant spec for variantName in this VariantSet at the stage's current EditTarget, in the position specified by position.
 
USD_API std::vector< std::string > GetVariantNames () const
 Return the composed variant names for this VariantSet, ordered lexicographically.
 
USD_API bool HasAuthoredVariant (const std::string &variantName) const
 Returns true if this VariantSet already possesses a variant.
 
USD_API std::string GetVariantSelection () const
 Return the variant selection for this VariantSet.
 
USD_API bool HasAuthoredVariantSelection (std::string *value=nullptr) const
 Returns true if there is a selection authored for this VariantSet in any layer.
 
USD_API bool SetVariantSelection (const std::string &variantName)
 Author a variant selection for this VariantSet, setting it to variantName in the stage's current EditTarget.
 
USD_API bool ClearVariantSelection ()
 Clear any selection for this VariantSet from the current EditTarget.
 
USD_API bool BlockVariantSelection ()
 Block any weaker selections for this VariantSet by authoring an empty string at the stage's current EditTarget.
 
USD_API UsdEditTarget GetVariantEditTarget (const SdfLayerHandle &layer=SdfLayerHandle()) const
 Return a UsdEditTarget that edits the currently selected variant in this VariantSet in layer.
 
USD_API std::pair< UsdStagePtr, UsdEditTargetGetVariantEditContext (const SdfLayerHandle &layer=SdfLayerHandle()) const
 Helper function for configuring a UsdStage's EditTarget to author into the currently selected variant.
 
UsdPrim const & GetPrim () const
 Return this VariantSet's held prim.
 
std::string const & GetName () const
 Return this VariantSet's name.
 
bool IsValid () const
 Is this UsdVariantSet object usable? If not, calling any of its other methods is likely to crash.
 
 operator bool () const
 Equivalent to IsValid().
 

Friends

class UsdPrim
 
class UsdVariantSets
 

Detailed Description

A UsdVariantSet represents a single VariantSet in USD (e.g.

modelingVariant or shadingVariant), which can have multiple variations that express different sets of opinions about the scene description rooted at the prim that defines the VariantSet.

(More detailed description of variants to follow)

Definition at line 39 of file variantSets.h.

Member Function Documentation

◆ AddVariant()

USD_API bool AddVariant ( const std::string &  variantName,
UsdListPosition  position = UsdListPositionBackOfPrependList 
)

Author a variant spec for variantName in this VariantSet at the stage's current EditTarget, in the position specified by position.

Return true if the spec was successfully authored, false otherwise.

This will create the VariantSet itself, if necessary, so as long as UsdPrim "prim" is valid, the following should always work:

UsdVariantSet vs = prim.GetVariantSet("myVariantSet");
vs.AddVariant("myFirstVariation");
vs.SetVariantSelection("myFirstVariation");
{
// Now all of our subsequent edits will go "inside" the
// 'myFirstVariation' variant of 'myVariantSet'
}
A utility class to temporarily modify a stage's current EditTarget during an execution scope.
Definition: editContext.h:51
A UsdVariantSet represents a single VariantSet in USD (e.g.
Definition: variantSets.h:39
USD_API bool AddVariant(const std::string &variantName, UsdListPosition position=UsdListPositionBackOfPrependList)
Author a variant spec for variantName in this VariantSet at the stage's current EditTarget,...
USD_API bool SetVariantSelection(const std::string &variantName)
Author a variant selection for this VariantSet, setting it to variantName in the stage's current Edit...
USD_API std::pair< UsdStagePtr, UsdEditTarget > GetVariantEditContext(const SdfLayerHandle &layer=SdfLayerHandle()) const
Helper function for configuring a UsdStage's EditTarget to author into the currently selected variant...

◆ BlockVariantSelection()

USD_API bool BlockVariantSelection ( )

Block any weaker selections for this VariantSet by authoring an empty string at the stage's current EditTarget.

Return true on success, false otherwise.

◆ ClearVariantSelection()

USD_API bool ClearVariantSelection ( )

Clear any selection for this VariantSet from the current EditTarget.

Return true on success, false otherwise.

◆ GetName()

std::string const & GetName ( ) const
inline

Return this VariantSet's name.

Definition at line 157 of file variantSets.h.

◆ GetPrim()

UsdPrim const & GetPrim ( ) const
inline

Return this VariantSet's held prim.

Definition at line 153 of file variantSets.h.

◆ GetVariantEditContext()

USD_API std::pair< UsdStagePtr, UsdEditTarget > GetVariantEditContext ( const SdfLayerHandle &  layer = SdfLayerHandle()) const

Helper function for configuring a UsdStage's EditTarget to author into the currently selected variant.

Returns configuration for a UsdEditContext

To begin editing into VariantSet varSet's currently selected variant:

In C++, we would use the following pattern:

{
UsdEditContext ctxt(varSet.GetVariantEditContext());
// All Usd mutation of the UsdStage on which varSet sits will
// now go "inside" the currently selected variant of varSet
}

In python, the pattern is:

with varSet.GetVariantEditContext():
# Now sending mutations to current variant

See GetVariantEditTarget() for discussion of layer parameter

◆ GetVariantEditTarget()

USD_API UsdEditTarget GetVariantEditTarget ( const SdfLayerHandle &  layer = SdfLayerHandle()) const

Return a UsdEditTarget that edits the currently selected variant in this VariantSet in layer.

If there is no currently selected variant in this VariantSet, return an invalid EditTarget.

If layer is unspecified, then we will use the layer of our prim's stage's current UsdEditTarget.

Currently, we require layer to be in the stage's local LayerStack (see UsdStage::HasLocalLayer()), and will issue an error and return an invalid EditTarget if layer is not. We may relax this restriction in the future, if need arises, but it introduces several complications in specification and behavior.

◆ GetVariantNames()

USD_API std::vector< std::string > GetVariantNames ( ) const

Return the composed variant names for this VariantSet, ordered lexicographically.

◆ GetVariantSelection()

USD_API std::string GetVariantSelection ( ) const

Return the variant selection for this VariantSet.

If there is no selection, return the empty string.

◆ HasAuthoredVariant()

USD_API bool HasAuthoredVariant ( const std::string &  variantName) const

Returns true if this VariantSet already possesses a variant.

◆ HasAuthoredVariantSelection()

USD_API bool HasAuthoredVariantSelection ( std::string *  value = nullptr) const

Returns true if there is a selection authored for this VariantSet in any layer.

If requested, the variant selection (if any) will be returned in value .

◆ IsValid()

bool IsValid ( ) const
inline

Is this UsdVariantSet object usable? If not, calling any of its other methods is likely to crash.

Definition at line 162 of file variantSets.h.

◆ operator bool()

operator bool ( ) const
inlineexplicit

Equivalent to IsValid().

Definition at line 167 of file variantSets.h.

◆ SetVariantSelection()

USD_API bool SetVariantSelection ( const std::string &  variantName)

Author a variant selection for this VariantSet, setting it to variantName in the stage's current EditTarget.

If variantName is empty, clear the variant selection (see ClearVariantSelection). Call BlockVariantSelection to explicitly set an empty variant selection.

Return true if the selection was successfully authored or cleared, false otherwise.

Friends And Related Function Documentation

◆ UsdPrim

friend class UsdPrim
friend

Definition at line 185 of file variantSets.h.

◆ UsdVariantSets

friend class UsdVariantSets
friend

Definition at line 186 of file variantSets.h.


The documentation for this class was generated from the following file: