All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UsdVariantSet Class Reference

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

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. More...
 
USD_API std::vector< std::string > GetVariantNames () const
 Return the composed variant names for this VariantSet, ordered lexicographically. More...
 
USD_API bool HasAuthoredVariant (const std::string &variantName) const
 Returns true if this VariantSet already possesses a variant. More...
 
USD_API std::string GetVariantSelection () const
 Return the variant selection for this VariantSet. More...
 
USD_API bool HasAuthoredVariantSelection (std::string *value=nullptr) const
 Returns true if there is a selection authored for this VariantSet in any layer. More...
 
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. More...
 
USD_API bool ClearVariantSelection ()
 Clear any selection for this VariantSet from the current EditTarget. More...
 
USD_API bool BlockVariantSelection ()
 Block any weaker selections for this VariantSet by authoring an empty string at the stage's current EditTarget. More...
 
USD_API UsdEditTarget GetVariantEditTarget (const SdfLayerHandle &layer=SdfLayerHandle()) const
 Return a UsdEditTarget that edits the currently selected variant in this VariantSet in layer. More...
 
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. More...
 
UsdPrim const & GetPrim () const
 Return this VariantSet's held prim. More...
 
std::string const & GetName () const
 Return this VariantSet's name. More...
 
bool IsValid () const
 Is this UsdVariantSet object usable? If not, calling any of its other methods is likely to crash. More...
 
 operator bool () const
 Equivalent to IsValid(). More...
 

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 56 of file variantSets.h.

Member Function Documentation

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'
* }
*
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.

USD_API bool ClearVariantSelection ( )

Clear any selection for this VariantSet from the current EditTarget.

Return true on success, false otherwise.

std::string const& GetName ( ) const
inline

Return this VariantSet's name.

Definition at line 174 of file variantSets.h.

UsdPrim const& GetPrim ( ) const
inline

Return this VariantSet's held prim.

Definition at line 170 of file variantSets.h.

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:

1 * with varSet.GetVariantEditContext():
2 * # Now sending mutations to current variant
3 *

See GetVariantEditTarget() for discussion of layer parameter

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.

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

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

USD_API std::string GetVariantSelection ( ) const

Return the variant selection for this VariantSet.

If there is no selection, return the empty string.

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

Returns true if this VariantSet already possesses a variant.

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 .

bool IsValid ( ) const
inline

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

Definition at line 179 of file variantSets.h.

operator bool ( ) const
inlineexplicit

Equivalent to IsValid().

Definition at line 184 of file variantSets.h.

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.


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