Loading...
Searching...
No Matches
UsdModelAPI Class Reference

UsdModelAPI is an API schema that provides an interface to a prim's model qualities, if it does, in fact, represent the root prim of a model. More...

#include <modelAPI.h>

+ Inheritance diagram for UsdModelAPI:

Public Member Functions

 UsdModelAPI (const UsdPrim &prim=UsdPrim())
 Construct a UsdModelAPI on UsdPrim prim .
 
 UsdModelAPI (const UsdSchemaBase &schemaObj)
 Construct a UsdModelAPI on the prim held by schemaObj .
 
virtual USD_API ~UsdModelAPI ()
 Destructor.
 
Model Asset Info API

USD_API bool GetAssetIdentifier (SdfAssetPath *identifier) const
 Returns the model's asset identifier as authored in the composed assetInfo dictionary.
 
USD_API void SetAssetIdentifier (const SdfAssetPath &identifier) const
 Sets the model's asset identifier to the given asset path, identifier.
 
USD_API bool GetAssetName (std::string *assetName) const
 Returns the model's asset name from the composed assetInfo dictionary.
 
USD_API void SetAssetName (const std::string &assetName) const
 Sets the model's asset name to assetName.
 
USD_API bool GetAssetVersion (std::string *version) const
 Returns the model's resolved asset version.
 
USD_API void SetAssetVersion (const std::string &version) const
 Sets the model's asset version string.
 
USD_API bool GetPayloadAssetDependencies (VtArray< SdfAssetPath > *assetDeps) const
 Returns the list of asset dependencies referenced inside the payload of the model.
 
USD_API void SetPayloadAssetDependencies (const VtArray< SdfAssetPath > &assetDeps) const
 Sets the list of external asset dependencies referenced inside the payload of a model.
 
USD_API bool GetAssetInfo (VtDictionary *info) const
 Returns the model's composed assetInfo dictionary.
 
USD_API void SetAssetInfo (const VtDictionary &info) const
 Sets the model's assetInfo dictionary to info in the current edit target.
 
- Public Member Functions inherited from UsdAPISchemaBase
 UsdAPISchemaBase (const UsdPrim &prim=UsdPrim())
 Construct a UsdAPISchemaBase on UsdPrim prim .
 
 UsdAPISchemaBase (const UsdSchemaBase &schemaObj)
 Construct a UsdAPISchemaBase on the prim held by schemaObj .
 
virtual USD_API ~UsdAPISchemaBase ()=0
 Destructor.
 
- Public Member Functions inherited from UsdSchemaBase
bool IsConcrete () const
 Returns whether or not this class corresponds to a concrete instantiable prim type in scene description.
 
bool IsTyped () const
 Returns whether or not this class inherits from UsdTyped.
 
bool IsAPISchema () const
 Returns whether this is an API schema or not.
 
bool IsAppliedAPISchema () const
 Returns whether this is an applied API schema or not.
 
bool IsMultipleApplyAPISchema () const
 Returns whether this is an applied API schema or not.
 
UsdSchemaKind GetSchemaKind () const
 Returns the kind of schema this class is.
 
USD_API UsdSchemaBase (const UsdPrim &prim=UsdPrim())
 Construct and store prim as the held prim.
 
USD_API UsdSchemaBase (const UsdSchemaBase &otherSchema)
 Construct and store for the same prim held by otherSchema.
 
virtual USD_API ~UsdSchemaBase ()
 Destructor.
 
UsdPrim GetPrim () const
 Return this schema object's held prim.
 
SdfPath GetPath () const
 Shorthand for GetPrim()->GetPath().
 
USD_API const UsdPrimDefinitionGetSchemaClassPrimDefinition () const
 Return the prim definition associated with this schema instance if one exists, otherwise return null.
 
USD_API operator bool () const
 Return true if this schema object is compatible with its held prim, false otherwise.
 

Static Public Member Functions

static USD_API const TfTokenVectorGetSchemaAttributeNames (bool includeInherited=true)
 Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes.
 
static USD_API UsdModelAPI Get (const UsdStagePtr &stage, const SdfPath &path)
 Return a UsdModelAPI holding the prim adhering to this schema at path on stage.
 
- Static Public Member Functions inherited from UsdAPISchemaBase
static USD_API const TfTokenVectorGetSchemaAttributeNames (bool includeInherited=true)
 Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes.
 
- Static Public Member Functions inherited from UsdSchemaBase
static const TfTokenVectorGetSchemaAttributeNames (bool includeInherited=true)
 

Static Public Attributes

static const UsdSchemaKind schemaKind = UsdSchemaKind::NonAppliedAPI
 Compile time constant representing what kind of schema this class is.
 
- Static Public Attributes inherited from UsdAPISchemaBase
static const UsdSchemaKind schemaKind = UsdSchemaKind::AbstractBase
 Compile time constant representing what kind of schema this class is.
 
- Static Public Attributes inherited from UsdSchemaBase
static const UsdSchemaKind schemaKind = UsdSchemaKind::AbstractBase
 Compile time constant representing what kind of schema this class is.
 

Protected Member Functions

USD_API UsdSchemaKind _GetSchemaKind () const override
 Returns the kind of schema this class belongs to.
 
template<typename T >
bool _GetAssetInfoByKey (const TfToken &key, T *val) const
 
- Protected Member Functions inherited from UsdAPISchemaBase
USD_API UsdSchemaKind _GetSchemaKind () const override
 Returns the kind of schema this class belongs to.
 
 UsdAPISchemaBase (const UsdPrim &prim, const TfToken &instanceName)
 Construct a multiple-apply UsdAPISchemaBase on UsdPrim prim with the specified instanceName.
 
 UsdAPISchemaBase (const UsdSchemaBase &schemaObj, const TfToken &instanceName)
 Construct a multiple-apply UsdAPISchemaBase on the prim held by schemaObj with the given instanceName.
 
const TfToken_GetInstanceName () const
 Returns the instance name of the API schema object belonging to a multiple-apply API schema.
 
USD_API bool _IsCompatible () const override
 Check whether this APISchema object is valid for the currently held
prim.
 
- Protected Member Functions inherited from UsdSchemaBase
virtual UsdSchemaKind _GetSchemaType () const
 
const TfType_GetType () const
 
USD_API UsdAttribute _CreateAttr (TfToken const &attrName, SdfValueTypeName const &typeName, bool custom, SdfVariability variability, VtValue const &defaultValue, bool writeSparsely) const
 

Friends

class UsdSchemaRegistry
 

Kind and Model-ness

enum  KindValidation { KindValidationNone , KindValidationModelHierarchy }
 Option for validating queries to a prim's kind metadata. More...
 
USD_API bool GetKind (TfToken *kind) const
 Retrieve the authored kind for this prim.
 
USD_API bool SetKind (const TfToken &kind) const
 Author a kind for this prim, at the current UsdEditTarget.
 
USD_API bool IsKind (const TfToken &baseKind, KindValidation validation=KindValidationModelHierarchy) const
 Return true if the prim's kind metadata is or inherits from baseKind as defined by the Kind Registry.
 
USD_API bool IsModel () const
 Return true if this prim represents a model, based on its kind metadata.
 
USD_API bool IsGroup () const
 Return true if this prim represents a model group, based on its kind metadata.
 

Additional Inherited Members

- Static Protected Member Functions inherited from UsdAPISchemaBase
static USD_API TfTokenVector _GetMultipleApplyInstanceNames (const UsdPrim &prim, const TfType &schemaType)
 Returns a vector of names of API schema objects belonging to a multiple-apply API schema applied to a given prim.
 

Detailed Description

UsdModelAPI is an API schema that provides an interface to a prim's model qualities, if it does, in fact, represent the root prim of a model.

The first and foremost model quality is its kind, i.e. the metadata that establishes it as a model (See KindRegistry). UsdModelAPI provides various methods for setting and querying the prim's kind, as well as queries (also available on UsdPrim) for asking what category of model the prim is. See Kind and Model-ness.

UsdModelAPI also provides access to a prim's assetInfo data. While any prim can host assetInfo, it is common that published (referenced) assets are packaged as models, therefore it is convenient to provide access to the one from the other.

Definition at line 72 of file modelAPI.h.

Member Enumeration Documentation

◆ KindValidation

Option for validating queries to a prim's kind metadata.

See also
IsKind()

Definition at line 161 of file modelAPI.h.

Constructor & Destructor Documentation

◆ UsdModelAPI() [1/2]

UsdModelAPI ( const UsdPrim prim = UsdPrim())
inlineexplicit

Construct a UsdModelAPI on UsdPrim prim .

Equivalent to UsdModelAPI::Get(prim.GetStage(), prim.GetPath()) for a valid prim, but will not immediately throw an error for an invalid prim

Definition at line 84 of file modelAPI.h.

◆ UsdModelAPI() [2/2]

UsdModelAPI ( const UsdSchemaBase schemaObj)
inlineexplicit

Construct a UsdModelAPI on the prim held by schemaObj .

Should be preferred over UsdModelAPI(schemaObj.GetPrim()), as it preserves SchemaBase state.

Definition at line 92 of file modelAPI.h.

◆ ~UsdModelAPI()

virtual USD_API ~UsdModelAPI ( )
virtual

Destructor.

Member Function Documentation

◆ _GetAssetInfoByKey()

bool _GetAssetInfoByKey ( const TfToken key,
T *  val 
) const
inlineprotected

Definition at line 314 of file modelAPI.h.

◆ _GetSchemaKind()

USD_API UsdSchemaKind _GetSchemaKind ( ) const
overrideprotectedvirtual

Returns the kind of schema this class belongs to.

See also
UsdSchemaKind

Reimplemented from UsdAPISchemaBase.

◆ Get()

static USD_API UsdModelAPI Get ( const UsdStagePtr &  stage,
const SdfPath path 
)
static

Return a UsdModelAPI holding the prim adhering to this schema at path on stage.

If no prim exists at path on stage, or if the prim at that path does not adhere to this schema, return an invalid schema object. This is shorthand for the following:

UsdModelAPI(stage->GetPrimAtPath(path));
UsdModelAPI is an API schema that provides an interface to a prim's model qualities,...
Definition: modelAPI.h:73

◆ GetAssetIdentifier()

USD_API bool GetAssetIdentifier ( SdfAssetPath identifier) const

Returns the model's asset identifier as authored in the composed assetInfo dictionary.

The asset identifier can be used to resolve the model's root layer via the asset resolver plugin.

◆ GetAssetInfo()

USD_API bool GetAssetInfo ( VtDictionary info) const

Returns the model's composed assetInfo dictionary.

The asset info dictionary is used to annotate models with various data related to asset management. For example, asset name, identifier, version etc.

The elements of this dictionary are composed element-wise, and are nestable.

◆ GetAssetName()

USD_API bool GetAssetName ( std::string *  assetName) const

Returns the model's asset name from the composed assetInfo dictionary.

The asset name is the name of the asset, as would be used in a database query.

◆ GetAssetVersion()

USD_API bool GetAssetVersion ( std::string *  version) const

Returns the model's resolved asset version.


If you publish assets with an embedded version, then you may receive that version string. You may, however, cause your authoring tools to record the resolved version at the time at which a reference to the asset was added to an aggregate, at the referencing site. In such a pipeline, this API will always return that stronger opinion, even if the asset is republished with a newer version, and even though that newer version may be the one that is resolved when the UsdStage is opened.

◆ GetKind()

USD_API bool GetKind ( TfToken kind) const

Retrieve the authored kind for this prim.

Returns
true if there was an authored kind that was successfully read, otherwise false.
See also
UsdPrim::GetKind

◆ GetPayloadAssetDependencies()

USD_API bool GetPayloadAssetDependencies ( VtArray< SdfAssetPath > *  assetDeps) const

Returns the list of asset dependencies referenced inside the payload of the model.

This typically contains identifiers of external assets that are referenced inside the model's payload. When the model is created, this list is compiled and set at the root of the model. This enables efficient dependency analysis without the need to include the model's payload.

◆ GetSchemaAttributeNames()

static USD_API const TfTokenVector & GetSchemaAttributeNames ( bool  includeInherited = true)
static

Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes.

Does not include attributes that may be authored by custom/extended methods of the schemas involved.

◆ IsGroup()

USD_API bool IsGroup ( ) const

Return true if this prim represents a model group, based on its kind metadata.

◆ IsKind()

USD_API bool IsKind ( const TfToken baseKind,
KindValidation  validation = KindValidationModelHierarchy 
) const

Return true if the prim's kind metadata is or inherits from baseKind as defined by the Kind Registry.

If validation is KindValidationModelHierarchy (the default), then this also ensures that if baseKind is a model, the prim conforms to the rules of model hierarchy, as defined by IsModel. If set to KindValidationNone, no additional validation is done.

IsModel and IsGroup are preferrable to IsKind("model") as they are optimized for fast traversal.

Note
If a prim's model hierarchy is not valid, it is possible that that prim.IsModel() and prim.IsKind("model", Usd.ModelAPI.KindValidationNone) return different answers. (As a corallary, this is also true for for prim.IsGroup())

◆ IsModel()

USD_API bool IsModel ( ) const

Return true if this prim represents a model, based on its kind metadata.

◆ SetAssetIdentifier()

USD_API void SetAssetIdentifier ( const SdfAssetPath identifier) const

Sets the model's asset identifier to the given asset path, identifier.

See also
GetAssetIdentifier()

◆ SetAssetInfo()

USD_API void SetAssetInfo ( const VtDictionary info) const

Sets the model's assetInfo dictionary to info in the current edit target.

◆ SetAssetName()

USD_API void SetAssetName ( const std::string &  assetName) const

Sets the model's asset name to assetName.

See also
GetAssetName()

◆ SetAssetVersion()

USD_API void SetAssetVersion ( const std::string &  version) const

Sets the model's asset version string.

See also
GetAssetVersion()

◆ SetKind()

USD_API bool SetKind ( const TfToken kind) const

Author a kind for this prim, at the current UsdEditTarget.

Returns
true if kind was successully authored, otherwise false.
See also
UsdPrim::SetKind

◆ SetPayloadAssetDependencies()

USD_API void SetPayloadAssetDependencies ( const VtArray< SdfAssetPath > &  assetDeps) const

Sets the list of external asset dependencies referenced inside the payload of a model.

See also
GetPayloadAssetDependencies()

Friends And Related Function Documentation

◆ UsdSchemaRegistry

friend class UsdSchemaRegistry
friend

Definition at line 131 of file modelAPI.h.

Member Data Documentation

◆ schemaKind

const UsdSchemaKind schemaKind = UsdSchemaKind::NonAppliedAPI
static

Compile time constant representing what kind of schema this class is.

See also
UsdSchemaKind

Definition at line 78 of file modelAPI.h.


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