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

#include <variantSets.h>

Public Member Functions

USD_API bool AddVariant (const std::string &variantName, UsdListPosition position=UsdListPositionBackOfPrependList)
USD_API std::vector< std::stringGetVariantNames () const
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
USD_API bool HasAuthoredVariantSelection (std::string *value=nullptr) const
USD_API bool SetVariantSelection (const std::string &variantName)
USD_API bool ClearVariantSelection ()
USD_API bool BlockVariantSelection ()
USD_API UsdEditTarget GetVariantEditTarget (const SdfLayerHandle &layer=SdfLayerHandle()) const
USD_API std::pair< UsdStagePtr,
GetVariantEditContext (const SdfLayerHandle &layer=SdfLayerHandle()) const
UsdPrim constGetPrim () const
 Return this VariantSet's held prim. More...
std::string constGetName () const
 Return this VariantSet's name. More...
bool IsValid () const
 operator bool () const
 Equivalent to IsValid(). More...


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 UsdVariantSet::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");
// Now all of our subsequent edits will go "inside" the
// 'myFirstVariation' variant of 'myVariantSet'
USD_API bool UsdVariantSet::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 UsdVariantSet::ClearVariantSelection ( )

Clear any selection for this VariantSet from the current EditTarget. Return true on success, false otherwise.

std::string const& UsdVariantSet::GetName ( ) const

Return this VariantSet's name.

Definition at line 174 of file variantSets.h.

UsdPrim const& UsdVariantSet::GetPrim ( ) const

Return this VariantSet's held prim.

Definition at line 170 of file variantSets.h.

USD_API std::pair<UsdStagePtr, UsdEditTarget> UsdVariantSet::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

See GetVariantEditTarget() for discussion of layer parameter

USD_API UsdEditTarget UsdVariantSet::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> UsdVariantSet::GetVariantNames ( ) const

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

USD_API std::string UsdVariantSet::GetVariantSelection ( ) const

Return the variant selection for this VariantSet. If there is no selection, return the empty string.

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

Returns true if this VariantSet already possesses a variant.

USD_API bool UsdVariantSet::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 UsdVariantSet::IsValid ( ) const

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.

UsdVariantSet::operator bool ( ) const

Equivalent to IsValid().

Definition at line 184 of file variantSets.h.

USD_API bool UsdVariantSet::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

friend class UsdPrim

Definition at line 202 of file variantSets.h.

friend class UsdVariantSets

Definition at line 203 of file variantSets.h.

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