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

#include <prim.h>

+ Inheritance diagram for UsdPrim:

Public Types

typedef UsdPrimSiblingIterator SiblingIterator
 Convenience typedefs. More...
 
typedef UsdPrimSiblingRange SiblingRange
 
typedef UsdPrimSubtreeIterator SubtreeIterator
 Convenience typedefs. More...
 
typedef UsdPrimSubtreeRange SubtreeRange
 
using PropertyPredicateFunc = std::function< bool(const TfToken &propertyName)>
 

Public Member Functions

 UsdPrim ()
 Construct an invalid prim. More...
 
USD_API SdfPrimSpecHandle GetPrimDefinition () const
 
SdfSpecifier GetSpecifier () const
 Return this prim's composed specifier. More...
 
USD_API SdfPrimSpecHandleVector GetPrimStack () const
 
bool SetSpecifier (SdfSpecifier specifier) const
 
const TfTokenGetTypeName () const
 
bool SetTypeName (const TfToken &typeName) const
 Author this Prim's typeName at the current EditTarget. More...
 
bool ClearTypeName () const
 
bool HasAuthoredTypeName () const
 Return true if a typeName has been authored. More...
 
bool IsActive () const
 
bool SetActive (bool active) const
 
bool ClearActive () const
 
bool HasAuthoredActive () const
 
bool IsLoaded () const
 
bool IsModel () const
 
bool IsGroup () const
 
bool IsAbstract () const
 Return true if this prim or any of its ancestors is a class. More...
 
bool IsDefined () const
 
bool HasDefiningSpecifier () const
 
USD_API TfTokenVector GetAppliedSchemas () const
 
USD_API TfTokenVector GetPropertyNames (const PropertyPredicateFunc &predicate={}) const
 
USD_API TfTokenVector GetAuthoredPropertyNames (const PropertyPredicateFunc &predicate={}) const
 
USD_API std::vector< UsdPropertyGetProperties (const PropertyPredicateFunc &predicate={}) const
 
USD_API std::vector< UsdPropertyGetAuthoredProperties (const PropertyPredicateFunc &predicate={}) const
 
USD_API std::vector< UsdPropertyGetPropertiesInNamespace (const std::vector< std::string > &namespaces) const
 
USD_API std::vector< UsdPropertyGetPropertiesInNamespace (const std::string &namespaces) const
 
USD_API std::vector< UsdPropertyGetAuthoredPropertiesInNamespace (const std::vector< std::string > &namespaces) const
 
USD_API std::vector< UsdPropertyGetAuthoredPropertiesInNamespace (const std::string &namespaces) const
 
USD_API TfTokenVector GetPropertyOrder () const
 Return the strongest propertyOrder metadata value authored on this prim. More...
 
USD_API void SetPropertyOrder (const TfTokenVector &order) const
 
USD_API bool RemoveProperty (const TfToken &propName)
 
USD_API UsdProperty GetProperty (const TfToken &propName) const
 
USD_API bool HasProperty (const TfToken &propName) const
 
template<typename T >
bool IsA () const
 
USD_API bool IsA (const TfType &schemaType) const
 Return true if prim type is/inherits a Schema with TfType schemaType. More...
 
template<typename T >
bool HasAPI (const TfToken &instanceName=TfToken()) const
 
USD_API bool HasAPI (const TfType &schemaType, const TfToken &instanceName=TfToken()) const
 
Prim Children
USD_API UsdPrim GetChild (const TfToken &name) const
 
SiblingRange GetChildren () const
 
SiblingRange GetAllChildren () const
 Return all this prim's children as an iterable range. More...
 
SiblingRange GetFilteredChildren (const Usd_PrimFlagsPredicate &predicate) const
 
SubtreeRange GetDescendants () const
 
SubtreeRange GetAllDescendants () const
 
SubtreeRange GetFilteredDescendants (const Usd_PrimFlagsPredicate &predicate) const
 
Parent & Stage
UsdPrim GetParent () const
 
USD_API UsdPrim GetNextSibling () const
 
USD_API UsdPrim GetFilteredNextSibling (const Usd_PrimFlagsPredicate &predicate) const
 
USD_API bool IsPseudoRoot () const
 
Variants
USD_API UsdVariantSets GetVariantSets () const
 
USD_API UsdVariantSet GetVariantSet (const std::string &variantSetName) const
 
USD_API bool HasVariantSets () const
 
Attributes
USD_API UsdAttribute CreateAttribute (const TfToken &name, const SdfValueTypeName &typeName, bool custom, SdfVariability variability=SdfVariabilityVarying) const
 
USD_API UsdAttribute CreateAttribute (const TfToken &name, const SdfValueTypeName &typeName, SdfVariability variability=SdfVariabilityVarying) const
 
USD_API UsdAttribute CreateAttribute (const std::vector< std::string > &nameElts, const SdfValueTypeName &typeName, bool custom, SdfVariability variability=SdfVariabilityVarying) const
 
USD_API UsdAttribute CreateAttribute (const std::vector< std::string > &nameElts, const SdfValueTypeName &typeName, SdfVariability variability=SdfVariabilityVarying) const
 
USD_API std::vector< UsdAttributeGetAttributes () const
 Like GetProperties(), but exclude all relationships from the result. More...
 
USD_API std::vector< UsdAttributeGetAuthoredAttributes () const
 
USD_API UsdAttribute GetAttribute (const TfToken &attrName) const
 
USD_API bool HasAttribute (const TfToken &attrName) const
 
USD_API SdfPathVector FindAllAttributeConnectionPaths (std::function< bool(UsdAttribute const &)> const &pred=nullptr, bool recurseOnSources=false) const
 
Relationships
USD_API UsdRelationship CreateRelationship (const TfToken &relName, bool custom=true) const
 
USD_API UsdRelationship CreateRelationship (const std::vector< std::string > &nameElts, bool custom=true) const
 
USD_API std::vector
< UsdRelationship
GetRelationships () const
 Like GetProperties(), but exclude all attributes from the result. More...
 
USD_API std::vector
< UsdRelationship
GetAuthoredRelationships () const
 
USD_API UsdRelationship GetRelationship (const TfToken &relName) const
 
USD_API bool HasRelationship (const TfToken &relName) const
 
USD_API SdfPathVector FindAllRelationshipTargetPaths (std::function< bool(UsdRelationship const &)> const &pred=nullptr, bool recurseOnTargets=false) const
 
Payload Authoring
Deprecated:
This API is now deprecated. Please use the HasAuthoredPayloads and the UsdPayloads API returned from GetPayloads() to query and author payloads instead.
USD_API bool ClearPayload () const
 
USD_API bool HasPayload () const
 
USD_API bool SetPayload (const SdfPayload &payload) const
 
USD_API bool SetPayload (const std::string &assetPath, const SdfPath &primPath) const
 
USD_API bool SetPayload (const SdfLayerHandle &layer, const SdfPath &primPath) const
 
Payloads, Load and Unload
USD_API UsdPayloads GetPayloads () const
 
USD_API bool HasAuthoredPayloads () const
 Return true if this prim has any authored payloads. More...
 
USD_API void Load (UsdLoadPolicy policy=UsdLoadWithDescendants) const
 
USD_API void Unload () const
 
References
USD_API UsdReferences GetReferences () const
 
USD_API bool HasAuthoredReferences () const
 Return true if this prim has any authored references. More...
 
Inherits
USD_API UsdInherits GetInherits () const
 
USD_API bool HasAuthoredInherits () const
 Return true if this prim has any authored inherits. More...
 
Specializes
USD_API UsdSpecializes GetSpecializes () const
 
USD_API bool HasAuthoredSpecializes () const
 Returns true if this prim has any authored specializes. More...
 
Instancing

See Usd_Page_ScenegraphInstancing for more details.

bool IsInstanceable () const
 
bool SetInstanceable (bool instanceable) const
 
bool ClearInstanceable () const
 
bool HasAuthoredInstanceable () const
 
bool IsInstance () const
 
bool IsInstanceProxy () const
 
bool IsMaster () const
 Return true if this prim is a master prim, false otherwise. More...
 
bool IsInMaster () const
 
USD_API UsdPrim GetMaster () const
 
UsdPrim GetPrimInMaster () const
 
Composition Structure
const PcpPrimIndexGetPrimIndex () const
 
USD_API PcpPrimIndex ComputeExpandedPrimIndex () const
 
- Public Member Functions inherited from UsdObject
 UsdObject ()
 Default constructor produces an invalid object. More...
 
template<typename T >
bool GetMetadata (const TfToken &key, T *value) const
 
USD_API bool GetMetadata (const TfToken &key, VtValue *value) const
 
template<typename T >
bool SetMetadata (const TfToken &key, const T &value) const
 
USD_API bool SetMetadata (const TfToken &key, const VtValue &value) const
 
USD_API bool ClearMetadata (const TfToken &key) const
 
USD_API bool HasMetadata (const TfToken &key) const
 
USD_API bool HasAuthoredMetadata (const TfToken &key) const
 
template<class T >
bool GetMetadataByDictKey (const TfToken &key, const TfToken &keyPath, T *value) const
 
USD_API bool GetMetadataByDictKey (const TfToken &key, const TfToken &keyPath, VtValue *value) const
 
template<typename T >
bool SetMetadataByDictKey (const TfToken &key, const TfToken &keyPath, const T &value) const
 
USD_API bool SetMetadataByDictKey (const TfToken &key, const TfToken &keyPath, const VtValue &value) const
 
USD_API bool ClearMetadataByDictKey (const TfToken &key, const TfToken &keyPath) const
 
USD_API bool HasMetadataDictKey (const TfToken &key, const TfToken &keyPath) const
 
USD_API bool HasAuthoredMetadataDictKey (const TfToken &key, const TfToken &keyPath) const
 
USD_API UsdMetadataValueMap GetAllMetadata () const
 
USD_API UsdMetadataValueMap GetAllAuthoredMetadata () const
 
USD_API bool IsHidden () const
 
USD_API bool SetHidden (bool hidden) const
 
USD_API bool ClearHidden () const
 Clears the opinion for "Hidden" at the current EditTarget. More...
 
USD_API bool HasAuthoredHidden () const
 
USD_API VtDictionary GetCustomData () const
 
USD_API VtValue GetCustomDataByKey (const TfToken &keyPath) const
 
USD_API void SetCustomData (const VtDictionary &customData) const
 
USD_API void SetCustomDataByKey (const TfToken &keyPath, const VtValue &value) const
 
USD_API void ClearCustomData () const
 
USD_API void ClearCustomDataByKey (const TfToken &keyPath) const
 
USD_API bool HasCustomData () const
 
USD_API bool HasCustomDataKey (const TfToken &keyPath) const
 
USD_API bool HasAuthoredCustomData () const
 
USD_API bool HasAuthoredCustomDataKey (const TfToken &keyPath) const
 
USD_API VtDictionary GetAssetInfo () const
 
USD_API VtValue GetAssetInfoByKey (const TfToken &keyPath) const
 
USD_API void SetAssetInfo (const VtDictionary &customData) const
 
USD_API void SetAssetInfoByKey (const TfToken &keyPath, const VtValue &value) const
 
USD_API void ClearAssetInfo () const
 
USD_API void ClearAssetInfoByKey (const TfToken &keyPath) const
 
USD_API bool HasAssetInfo () const
 
USD_API bool HasAssetInfoKey (const TfToken &keyPath) const
 
USD_API bool HasAuthoredAssetInfo () const
 
USD_API bool HasAuthoredAssetInfoKey (const TfToken &keyPath) const
 
USD_API std::string GetDocumentation () const
 
USD_API bool SetDocumentation (const std::string &doc) const
 Sets this object's documentation (metadata). Returns true on success. More...
 
USD_API bool ClearDocumentation () const
 
USD_API bool HasAuthoredDocumentation () const
 
bool IsValid () const
 Return true if this is a valid object, false otherwise. More...
 
 operator bool () const
 Returns true if this object is valid, false otherwise. More...
 
USD_API UsdStageWeakPtr GetStage () const
 
SdfPath GetPath () const
 
const SdfPathGetPrimPath () const
 
UsdPrim GetPrim () const
 
const TfTokenGetName () const
 
template<class T >
T As () const
 
template<class T >
bool Is () const
 
USD_API std::string GetDescription () const
 

Friends

class UsdObject
 
class UsdPrimSiblingIterator
 
class UsdPrimSubtreeIterator
 
class UsdProperty
 
class UsdSchemaBase
 
class UsdAPISchemaBase
 
class UsdStage
 
class UsdPrimRange
 
class Usd_PrimData
 
class Usd_PrimFlagsPredicate
 
struct UsdPrim_RelTargetFinder
 
struct UsdPrim_AttrConnectionFinder
 
const PcpPrimIndexUsd_PrimGetSourcePrimIndex (const UsdPrim &)
 

Additional Inherited Members

- Static Public Member Functions inherited from UsdObject
static char GetNamespaceDelimiter ()
 
- Protected Member Functions inherited from UsdObject
 UsdObject (const Usd_PrimDataHandle &prim, const SdfPath &proxyPrimPath)
 
 UsdObject (UsdObjType objType, const Usd_PrimDataHandle &prim, const SdfPath &proxyPrimPath, const TfToken &propName)
 
UsdStage_GetStage () const
 
USD_API SdfSpecType _GetDefiningSpecType () const
 
const Usd_PrimDataHandle_Prim () const
 
const TfToken_PropName () const
 
const SdfPath_ProxyPrimPath () const
 

Detailed Description

UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as described in the Universal Scene Description Composition Compendium

A UsdPrim is the principal container of other types of scene description. It provides API for accessing and creating all of the contained kinds of scene description, which include:

As well as access to the API objects for properties contained within the prim - UsdPrim as well as all of the following classes are subclasses of UsdObject:

UsdPrim also provides access to iteration through its prim children, optionally making use of the prim predicates facility (GetChildren(), GetAllChildren(), GetFilteredChildren()).

Management

Clients acquire UsdPrim objects, which act like weak/guarded pointers to persistent objects owned and managed by their originating UsdStage. We provide the following guarantees for a UsdPrim acquired via UsdStage::GetPrimAtPath() or UsdStage::OverridePrim() or UsdStage::DefinePrim():

  • As long as no further mutations to the structure of the UsdStage are made, the UsdPrim will still be valid. Loading and Unloading are considered structural mutations.
  • When the UsdStage's structure is mutated, the thread performing the mutation will receive a UsdNotice::ObjectsChanged notice after the stage has been reconfigured, which provides details as to what prims may have been created or destroyed, and what prims may simply have changed in some structural way.

Prim access in "reader" threads should be limited to GetPrimAtPath(), which will never cause a mutation to the Stage or its layers.

Please refer to UsdNotice for a listing of the events that could cause UsdNotice::ObjectsChanged to be emitted.

Examples:
LOP/LOP_Sphere.C, and USD/ROP_usdoutput.h.

Definition at line 131 of file prim.h.

Member Typedef Documentation

using UsdPrim::PropertyPredicateFunc = std::function<bool (const TfToken &propertyName)>

Alias for the "predicate" function parameter passed into the various Get{Authored}{PropertyNames,Properties} methods.

Definition at line 258 of file prim.h.

Convenience typedefs.

Definition at line 135 of file prim.h.

Definition at line 136 of file prim.h.

Convenience typedefs.

Definition at line 139 of file prim.h.

Definition at line 140 of file prim.h.

Constructor & Destructor Documentation

UsdPrim::UsdPrim ( )
inline

Construct an invalid prim.

Definition at line 143 of file prim.h.

Member Function Documentation

bool UsdPrim::ClearActive ( ) const
inline

Remove the authored 'active' opinion at the current EditTarget. Do nothing if there is no authored opinion.

See Usd_ActiveInactive for the effects of activating or deactivating a prim.

Definition at line 210 of file prim.h.

bool UsdPrim::ClearInstanceable ( ) const
inline

Remove the authored 'instanceable' opinion at the current EditTarget. Do nothing if there is no authored opinion.

Definition at line 1072 of file prim.h.

USD_API bool UsdPrim::ClearPayload ( ) const
Deprecated:
Clears the payload at the current EditTarget for this prim. Return false if the payload could not be cleared.
bool UsdPrim::ClearTypeName ( ) const
inline

Clear the opinion for this Prim's typeName at the current edit target.

Definition at line 182 of file prim.h.

USD_API PcpPrimIndex UsdPrim::ComputeExpandedPrimIndex ( ) const

Compute the prim index containing all sites that could contribute opinions to this prim.

This function is similar to UsdPrim::GetPrimIndex. However, the returned prim index includes all sites that could possibly contribute opinions to this prim, not just the sites that currently do so. This is useful in certain situations; for example, this could be used to generate a list of sites where clients could make edits to affect this prim, or for debugging purposes.

This function may be relatively slow, since it will recompute the prim index on every call. Clients should prefer UsdPrim::GetPrimIndex unless the additional site information is truly needed.

USD_API UsdAttribute UsdPrim::CreateAttribute ( const TfToken name,
const SdfValueTypeName typeName,
bool  custom,
SdfVariability  variability = SdfVariabilityVarying 
) const

Author scene description for the attribute named attrName at the current EditTarget if none already exists. Return a valid attribute if scene description was successfully authored or if it already existed, return invalid attribute otherwise. Note that the supplied typeName and custom arguments are only used in one specific case. See below for details.

Suggested use:

if (UsdAttribute myAttr = prim.CreateAttribute(...)) {
// success.
}

To call this, GetPrim() must return a valid prim.

  • If a spec for this attribute already exists at the current edit target, do nothing.
  • If a spec for attrName of a different spec type (e.g. a relationship) exists at the current EditTarget, issue an error.
  • If name refers to a builtin attribute according to the prim's definition, author an attribute spec with required metadata from the definition.
  • If name refers to a builtin relationship, issue an error.
  • If there exists an absolute strongest authored attribute spec for attrName, author an attribute spec at the current EditTarget by copying required metadata from that strongest spec.
  • If there exists an absolute strongest authored relationship spec for attrName, issue an error.
  • Otherwise author an attribute spec at the current EditTarget using the provided typeName and custom for the required metadata fields. Note that these supplied arguments are only ever used in this particular circumstance, in all other cases they are ignored.
USD_API UsdAttribute UsdPrim::CreateAttribute ( const TfToken name,
const SdfValueTypeName typeName,
SdfVariability  variability = SdfVariabilityVarying 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Create a custom attribute with name, typeName and variability.

USD_API UsdAttribute UsdPrim::CreateAttribute ( const std::vector< std::string > &  nameElts,
const SdfValueTypeName typeName,
bool  custom,
SdfVariability  variability = SdfVariabilityVarying 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This overload of CreateAttribute() accepts a vector of name components used to construct a namespaced property name. For details, see Usd_Ordering

USD_API UsdAttribute UsdPrim::CreateAttribute ( const std::vector< std::string > &  nameElts,
const SdfValueTypeName typeName,
SdfVariability  variability = SdfVariabilityVarying 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Create a custom attribute with nameElts, typeName, and variability.

USD_API UsdRelationship UsdPrim::CreateRelationship ( const TfToken relName,
bool  custom = true 
) const

Author scene description for the relationship named relName at the current EditTarget if none already exists. Return a valid relationship if scene description was successfully authored or if it already existed, return an invalid relationship otherwise.

Suggested use:

if (UsdRelationship myRel = prim.CreateRelationship(...)) {
// success.
}

To call this, GetPrim() must return a valid prim.

  • If a spec for this relationship already exists at the current edit target, do nothing.
  • If a spec for relName of a different spec type (e.g. an attribute) exists at the current EditTarget, issue an error.
  • If name refers to a builtin relationship according to the prim's definition, author a relationship spec with required metadata from the definition.
  • If name refers to a builtin attribute, issue an error.
  • If there exists an absolute strongest authored relationship spec for relName, author a relationship spec at the current EditTarget by copying required metadata from that strongest spec.
  • If there exists an absolute strongest authored attribute spec for relName, issue an error.
  • Otherwise author a uniform relationship spec at the current EditTarget, honoring custom .
USD_API UsdRelationship UsdPrim::CreateRelationship ( const std::vector< std::string > &  nameElts,
bool  custom = true 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This overload of CreateRelationship() accepts a vector of name components used to construct a namespaced property name. For details, see Usd_Ordering

USD_API SdfPathVector UsdPrim::FindAllAttributeConnectionPaths ( std::function< bool(UsdAttribute const &)> const pred = nullptr,
bool  recurseOnSources = false 
) const

Search the prim subtree rooted at this prim for attributes for which predicate returns true, collect their connection source paths and return them in an arbitrary order. If recurseOnSources is true, act as if this function was invoked on the connected prims and owning prims of connected properties also and return the union.

USD_API SdfPathVector UsdPrim::FindAllRelationshipTargetPaths ( std::function< bool(UsdRelationship const &)> const pred = nullptr,
bool  recurseOnTargets = false 
) const

Search the prim subtree rooted at this prim for relationships for which predicate returns true, collect their target paths and return them in an arbitrary order. If recurseOnTargets is true, act as if this function was invoked on the targeted prims and owning prims of targeted properties also (but not of forwarding relationships) and return the union.

UsdPrimSiblingRange UsdPrim::GetAllChildren ( ) const
inline

Return all this prim's children as an iterable range.

Definition at line 1415 of file prim.h.

UsdPrimSubtreeRange UsdPrim::GetAllDescendants ( ) const
inline

Return all this prim's descendants as an iterable range.

Note
This method is not yet available in python, pending some refactoring to make it more feasible.

See Prim predicate flags and UsdPrimDefaultPredicate for more information, UsdStage::Traverse(), and UsdPrimRange for more general Stage traversal behaviors.

Definition at line 1612 of file prim.h.

USD_API TfTokenVector UsdPrim::GetAppliedSchemas ( ) const

Return a vector containing the names of API schemas which have been applied to this prim, using the Apply() method on the particular schema class.

USD_API UsdAttribute UsdPrim::GetAttribute ( const TfToken attrName) const

Return a UsdAttribute with the name attrName. The attribute returned may or may not actually exist so it must be checked for validity. Suggested use:

if (UsdAttribute myAttr = prim.GetAttribute("myAttr")) {
// myAttr is safe to use.
// Edits to the owning stage requires subsequent validation.
} else {
// myAttr was not defined/authored
}
Examples:
LOP/LOP_Sphere.C.
USD_API std::vector<UsdAttribute> UsdPrim::GetAttributes ( ) const

Like GetProperties(), but exclude all relationships from the result.

USD_API std::vector<UsdAttribute> UsdPrim::GetAuthoredAttributes ( ) const

Like GetAttributes(), but exclude attributes without authored scene description from the result. See UsdProperty::IsAuthored().

USD_API std::vector<UsdProperty> UsdPrim::GetAuthoredProperties ( const PropertyPredicateFunc predicate = {}) const

Return this prim's properties (attributes and relationships) that have authored scene description, ordered by name according to the strongest propertyOrder statement in scene description if one exists, otherwise ordered according to TfDictionaryLessThan.

If a valid predicate is passed in, then only authored properties whose names pass the predicate are included in the result. This is useful if the client is interested only in a subset of authored properties on the prim. For example, only the ones in a given namespace or only the ones needed to compute a value.

See Also
GetProperties()
UsdProperty::IsAuthored()
USD_API std::vector<UsdProperty> UsdPrim::GetAuthoredPropertiesInNamespace ( const std::vector< std::string > &  namespaces) const

Like GetPropertiesInNamespace(), but exclude properties that do not have authored scene description from the result. See UsdProperty::IsAuthored().

For details of namespaced properties, see Usd_Ordering

USD_API std::vector<UsdProperty> UsdPrim::GetAuthoredPropertiesInNamespace ( const std::string namespaces) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. namespaces must be an already-concatenated ordered set of namespaces, and may or may not terminate with the namespace-separator character. If namespaces is empty, this method is equivalent to GetAuthoredProperties().

USD_API TfTokenVector UsdPrim::GetAuthoredPropertyNames ( const PropertyPredicateFunc predicate = {}) const

Return this prim's property names (attributes and relationships) that have authored scene description, ordered according to the strongest propertyOrder statement in scene description if one exists, otherwise ordered according to TfDictionaryLessThan.

If a valid predicate is passed in, then only the authored properties whose names pass the predicate are included in the result. This is useful if the client is interested only in a subset of authored properties on the prim. For example, only the ones in a given namespace or only the ones needed to compute a value.

See Also
GetPropertyNames()
UsdProperty::IsAuthored()
USD_API std::vector<UsdRelationship> UsdPrim::GetAuthoredRelationships ( ) const

Like GetRelationships(), but exclude relationships without authored scene description from the result. See UsdProperty::IsAuthored().

USD_API UsdPrim UsdPrim::GetChild ( const TfToken name) const

Return this prim's direct child named name if it has one, otherwise return an invalid UsdPrim. Equivalent to:

prim.GetStage()->GetPrimAtPath(prim.GetPath().AppendChild(name))
UsdPrimSiblingRange UsdPrim::GetChildren ( ) const
inline

Return this prim's active, loaded, defined, non-abstract children as an iterable range. Equivalent to:

See Prim predicate flags and UsdPrimDefaultPredicate for more information.

Definition at line 1421 of file prim.h.

UsdPrimSubtreeRange UsdPrim::GetDescendants ( ) const
inline

Return this prim's active, loaded, defined, non-abstract descendants as an iterable range. Equivalent to:

Note
This method is not yet available in python, pending some refactoring to make it more feasible.

See Prim predicate flags and UsdPrimDefaultPredicate for more information, UsdStage::Traverse(), and UsdPrimRange for more general Stage traversal behaviors.

Definition at line 1618 of file prim.h.

UsdPrimSiblingRange UsdPrim::GetFilteredChildren ( const Usd_PrimFlagsPredicate predicate) const
inline

Return a subset of all of this prim's children filtered by predicate as an iterable range. The predicate is generated by combining a series of prim flag terms with either && or || and !.

Example usage:

// Get all active model children.
GetFilteredChildren(UsdPrimIsActive && UsdPrimIsModel);
// Get all model children that pass the default predicate.

If this prim is an instance, no children will be returned unless UsdTraverseInstanceProxies is used to allow instance proxies to be returned, or if this prim is itself an instance proxy.

See Prim predicate flags and UsdPrimDefaultPredicate for more information.

Definition at line 1408 of file prim.h.

UsdPrimSubtreeRange UsdPrim::GetFilteredDescendants ( const Usd_PrimFlagsPredicate predicate) const
inline

Return a subset of all of this prim's descendants filtered by predicate as an iterable range. The predicate is generated by combining a series of prim flag terms with either && or || and !.

Example usage:

// Get all active model descendants.
GetFilteredDescendants(UsdPrimIsActive && UsdPrimIsModel);
// Get all model descendants that pass the default predicate.

If this prim is an instance, no descendants will be returned unless UsdTraverseInstanceProxies is used to allow instance proxies to be returned, or if this prim is itself an instance proxy.

Note
This method is not yet available in python, pending some refactoring to make it more feasible.

See Prim predicate flags and UsdPrimDefaultPredicate for more information, UsdStage::Traverse(), and UsdPrimRange for more general Stage traversal behaviors.

Definition at line 1605 of file prim.h.

USD_API UsdPrim UsdPrim::GetFilteredNextSibling ( const Usd_PrimFlagsPredicate predicate) const

Return this prim's next sibling that matches predicate if it has one, otherwise return the invalid UsdPrim.

See Prim predicate flags and UsdPrimDefaultPredicate for more information.

USD_API UsdInherits UsdPrim::GetInherits ( ) const

Return a UsdInherits object that allows one to add, remove, or mutate inherits at the currently set UsdEditTarget.

There is currently no facility for listing the currently authored inherits on a prim... the problem is somewhat ill-defined, and requires some thought.

USD_API UsdPrim UsdPrim::GetMaster ( ) const

If this prim is an instance, return the UsdPrim for the corresponding master. Otherwise, return an invalid UsdPrim.

USD_API UsdPrim UsdPrim::GetNextSibling ( ) const

Return this prim's next active, loaded, defined, non-abstract sibling if it has one, otherwise return an invalid UsdPrim. Equivalent to:

See Prim predicate flags and UsdPrimDefaultPredicate for more information.

UsdPrim UsdPrim::GetParent ( ) const
inline

Return this prim's parent prim. Return an invalid UsdPrim if this is a root prim.

Definition at line 644 of file prim.h.

USD_API UsdPayloads UsdPrim::GetPayloads ( ) const

Return a UsdPayloads object that allows one to add, remove, or mutate payloads at the currently set UsdEditTarget.

There is currently no facility for listing the currently authored payloads on a prim... the problem is somewhat ill-defined, and requires some thought.

USD_API SdfPrimSpecHandle UsdPrim::GetPrimDefinition ( ) const

Return this prim's definition from the UsdSchemaRegistry based on the prim's type if one exists, otherwise return null.

const PcpPrimIndex& UsdPrim::GetPrimIndex ( ) const
inline

Return the cached prim index containing all sites that contribute opinions to this prim.

The prim index can be used to examine the composition arcs and scene description sites that contribute to this prim's property and metadata values.

The prim index returned by this function is optimized and may not include sites that do not contribute opinions to this prim. Use UsdPrim::ComputeExpandedPrimIndex to compute a prim index that includes all possible sites that could contribute opinions.

This prim index will be empty for master prims. This ensures that these prims do not provide any attribute or metadata values. For all other prims in masters, this is the prim index that was chosen to be shared with all other instances. In either case, the prim index's path will not be the same as the prim's path.

Prim indexes may be invalidated by changes to the UsdStage and cannot detect if they are expired. Clients should avoid keeping copies of the prim index across such changes, which include scene description changes or changes to load state.

Definition at line 1153 of file prim.h.

UsdPrim UsdPrim::GetPrimInMaster ( ) const
inline

If this prim is an instance proxy, return the UsdPrim for the corresponding prim in the instance's master. Otherwise, return an invalid UsdPrim.

Definition at line 1117 of file prim.h.

USD_API SdfPrimSpecHandleVector UsdPrim::GetPrimStack ( ) const

Return a list of PrimSpecs that provide opinions for this prim (i.e. the prim's metadata fields, including composition metadata). These specs are ordered from strongest to weakest opinion.

Note
The results returned by this method are meant for debugging and diagnostic purposes. It is not advisable to retain a PrimStack for the purposes of expedited value resolution for prim metadata, since not all metadata resolves with simple "strongest opinion wins" semantics.
USD_API std::vector<UsdProperty> UsdPrim::GetProperties ( const PropertyPredicateFunc predicate = {}) const

Return all of this prim's properties (attributes and relationships), including all builtin properties, ordered by name according to the strongest propertyOrder statement in scene description if one exists, otherwise ordered according to TfDictionaryLessThan.

If a valid predicate is passed in, then only properties whose names pass the predicate are included in the result. This is useful if the client is interested only in a subset of properties on the prim. For example, only the ones in a given namespace or only the ones needed to compute a value.

To obtain only either attributes or relationships, use either GetAttributes() or GetRelationships().

To determine whether a property is either an attribute or a relationship, use the UsdObject::As() and UsdObject::Is() methods in C++:

// Use As<>() to obtain a subclass instance.
// use attribute 'attr'.
// use relationship 'rel'.
}
// Use Is<>() to discriminate only.
if (property.Is<UsdAttribute>()) {
// property is an attribute.
}

In Python, use the standard isinstance() function:

if isinstance(property, Usd.Attribute):
# property is a Usd.Attribute.
elif isinstance(property, Usd.Relationship):
# property is a Usd.Relationship.
See Also
GetAuthoredProperties()
UsdProperty::IsAuthored()
USD_API std::vector<UsdProperty> UsdPrim::GetPropertiesInNamespace ( const std::vector< std::string > &  namespaces) const

Return this prim's properties that are inside the given property namespace ordered according to the strongest propertyOrder statement in scene description if one exists, otherwise ordered according to TfDictionaryLessThan.

A namespaces argument whose elements are ["ri", "attribute"] will return all the properties under the namespace "ri:attribute", i.e. "ri:attribute:*". An empty namespaces argument is equivalent to GetProperties().

For details of namespaced properties, see Usd_Ordering

USD_API std::vector<UsdProperty> UsdPrim::GetPropertiesInNamespace ( const std::string namespaces) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. namespaces must be an already-concatenated ordered set of namespaces, and may or may not terminate with the namespace-separator character. If namespaces is empty, this method is equivalent to GetProperties().

USD_API UsdProperty UsdPrim::GetProperty ( const TfToken propName) const

Return a UsdProperty with the name propName. The property returned may or may not actually exist so it must be checked for validity. Suggested use:

if (UsdProperty myProp = prim.GetProperty("myProp")) {
// myProp is safe to use.
// Edits to the owning stage requires subsequent validation.
} else {
// myProp was not defined/authored
}
USD_API TfTokenVector UsdPrim::GetPropertyNames ( const PropertyPredicateFunc predicate = {}) const

Return all of this prim's property names (attributes and relationships), including all builtin properties.

If a valid predicate is passed in, then only properties whose names pass the predicate are included in the result. This is useful if the client is interested only in a subset of properties on the prim. For example, only the ones in a given namespace or only the ones needed to compute a value.

See Also
GetAuthoredPropertyNames()
UsdProperty::IsAuthored()
USD_API TfTokenVector UsdPrim::GetPropertyOrder ( ) const

Return the strongest propertyOrder metadata value authored on this prim.

USD_API UsdReferences UsdPrim::GetReferences ( ) const

Return a UsdReferences object that allows one to add, remove, or mutate references at the currently set UsdEditTarget.

There is currently no facility for listing the currently authored references on a prim... the problem is somewhat ill-defined, and requires some thought.

USD_API UsdRelationship UsdPrim::GetRelationship ( const TfToken relName) const

Return a UsdRelationship with the name relName. The relationship returned may or may not actually exist so it must be checked for validity. Suggested use:

if (UsdRelationship myRel = prim.GetRelationship("myRel")) {
// myRel is safe to use.
// Edits to the owning stage requires subsequent validation.
} else {
// myRel was not defined/authored
}
USD_API std::vector<UsdRelationship> UsdPrim::GetRelationships ( ) const

Like GetProperties(), but exclude all attributes from the result.

USD_API UsdSpecializes UsdPrim::GetSpecializes ( ) const

Return a UsdSpecializes object that allows one to add, remove, or mutate specializes at the currently set UsdEditTarget.

There is currently no facility for listing the currently authored specializes on a prim... the problem is somewhat ill-defined, and requires some thought.

SdfSpecifier UsdPrim::GetSpecifier ( ) const
inline

Return this prim's composed specifier.

Definition at line 151 of file prim.h.

const TfToken& UsdPrim::GetTypeName ( ) const
inline

Return this prim's composed type name. Note that this value is cached and is efficient to query.

Definition at line 173 of file prim.h.

USD_API UsdVariantSet UsdPrim::GetVariantSet ( const std::string variantSetName) const

Retrieve a specifically named VariantSet for editing or constructing a UsdEditTarget.

This is a shortcut for

prim.GetVariantSets().GetVariantSet(variantSetName)
USD_API UsdVariantSets UsdPrim::GetVariantSets ( ) const

Return a UsdVariantSets object representing all the VariantSets present on this prim.

The returned object also provides the API for adding new VariantSets to the prim.

template<typename T >
bool UsdPrim::HasAPI ( const TfToken instanceName = TfToken()) const
inline

Return true if the UsdPrim has had an API schema represented by the C++ class type T applied to it through the Apply() method provided on the API schema class.

instanceName, if non-empty is used to determine if a particular instance of a multiple-apply API schema (eg. UsdCollectionAPI) has been applied to the prim. A coding error is issued if a non-empty instanceName is passed in and T represents a single-apply API schema.

Using HasAPI in C++

UsdPrim prim = stage->OverridePrim("/path/to/prim");
UsdModelAPI modelAPI = UsdModelAPI::Apply(prim);
assert(prim.HasAPI<UsdModelAPI>());
UsdCollectionAPI collAPI = UsdCollectionAPI::Apply(prim,
/*instanceName*/ TfToken("geom"))
assert(prim.HasAPI<UsdCollectionAPI>()
assert(prim.HasAPI<UsdCollectionAPI>(/*instanceName*/ TfToken("geom")))

The python version of this method takes as an argument the TfType of the API schema class. Similar validation of the schema type is performed in python at run-time and a coding error is issued if the given type is not a valid applied API schema.

Using HasAPI in Python

1 prim = stage.OverridePrim("/path/to/prim")
2 modelAPI = Usd.ModelAPI.Apply(prim)
3 assert prim.HasAPI(Usd.ModelAPI)
4 
5 collAPI = Usd.CollectionAPI.Apply(prim, "geom")
6 assert(prim.HasAPI(Usd.CollectionAPI))
7 assert(prim.HasAPI(Usd.CollectionAPI, instanceName="geom"))

Definition at line 506 of file prim.h.

USD_API bool UsdPrim::HasAPI ( const TfType schemaType,
const TfToken instanceName = TfToken() 
) const

Return true if a prim has an API schema with TfType schemaType.

instanceName, if non-empty is used to determine if a particular instance of a multiple-apply API schema (eg. UsdCollectionAPI) has been applied to the prim. A coding error is issued if a non-empty instanceName is passed in and T represents a single-apply API schema.

USD_API bool UsdPrim::HasAttribute ( const TfToken attrName) const

Return true if this prim has an attribute named attrName, false otherwise.

bool UsdPrim::HasAuthoredActive ( ) const
inline

Return true if this prim has an authored opinion for 'active', false otherwise.

See Usd_ActiveInactive for what it means for a prim to be active.

Definition at line 218 of file prim.h.

USD_API bool UsdPrim::HasAuthoredInherits ( ) const

Return true if this prim has any authored inherits.

bool UsdPrim::HasAuthoredInstanceable ( ) const
inline

Return true if this prim has an authored opinion for 'instanceable', false otherwise.

Definition at line 1078 of file prim.h.

USD_API bool UsdPrim::HasAuthoredPayloads ( ) const

Return true if this prim has any authored payloads.

USD_API bool UsdPrim::HasAuthoredReferences ( ) const

Return true if this prim has any authored references.

USD_API bool UsdPrim::HasAuthoredSpecializes ( ) const

Returns true if this prim has any authored specializes.

bool UsdPrim::HasAuthoredTypeName ( ) const
inline

Return true if a typeName has been authored.

Definition at line 187 of file prim.h.

bool UsdPrim::HasDefiningSpecifier ( ) const
inline

Return true if this prim has a specifier of type SdfSpecifierDef or SdfSpecifierClass.

See Also
SdfIsDefiningSpecifier

Definition at line 245 of file prim.h.

USD_API bool UsdPrim::HasPayload ( ) const
Deprecated:
Return true if a payload is present on this prim.
See Also
Usd_Payloads
USD_API bool UsdPrim::HasProperty ( const TfToken propName) const

Return true if this prim has an property named propName, false otherwise.

USD_API bool UsdPrim::HasRelationship ( const TfToken relName) const

Return true if this prim has a relationship named relName, false otherwise.

USD_API bool UsdPrim::HasVariantSets ( ) const

Return true if this prim has any authored VariantSets.

Note
this connotes only the existence of one of more VariantSets, not that such VariantSets necessarily contain any variants or variant opinions.
template<typename T >
bool UsdPrim::IsA ( ) const
inline

Return true if the UsdPrim is/inherits a Schema of type T.

This will also return true if the UsdPrim is a schema that inherits from schema T.

Definition at line 458 of file prim.h.

USD_API bool UsdPrim::IsA ( const TfType schemaType) const

Return true if prim type is/inherits a Schema with TfType schemaType.

bool UsdPrim::IsAbstract ( ) const
inline

Return true if this prim or any of its ancestors is a class.

Definition at line 237 of file prim.h.

bool UsdPrim::IsActive ( ) const
inline

Return true if this prim is active, meaning neither it nor any of its ancestors have active=false. Return false otherwise.

See Usd_ActiveInactive for what it means for a prim to be active.

Definition at line 195 of file prim.h.

bool UsdPrim::IsDefined ( ) const
inline

Return true if this prim and all its ancestors have defining specifiers, false otherwise.

See Also
SdfIsDefiningSpecifier.

Definition at line 241 of file prim.h.

bool UsdPrim::IsGroup ( ) const
inline

Return true if this prim is a model group based on its kind metadata, false otherwise. If this prim is a group, it is also necessarily a model.

Definition at line 234 of file prim.h.

bool UsdPrim::IsInMaster ( ) const
inline

Return true if this prim is located in a subtree of prims rooted at a master prim, false otherwise.

If this function returns true, this prim is either a master prim or a descendent of a master prim.

Definition at line 1104 of file prim.h.

bool UsdPrim::IsInstance ( ) const
inline

Return true if this prim is an instance of a master, false otherwise.

If this prim is an instance, calling GetMaster() will return the UsdPrim for the corresponding master prim.

Definition at line 1087 of file prim.h.

bool UsdPrim::IsInstanceable ( ) const
inline

Return true if this prim has been marked as instanceable.

Note that this is not the same as IsInstance(). A prim may return true for IsInstanceable() and false for IsInstance() if this prim is not active or if it is marked as instanceable but contains no instanceable data.

Definition at line 1058 of file prim.h.

bool UsdPrim::IsInstanceProxy ( ) const
inline

Return true if this prim is an instance proxy, false otherwise. An instance proxy prim represents a descendent of an instance prim.

Definition at line 1092 of file prim.h.

bool UsdPrim::IsLoaded ( ) const
inline

Return true if this prim is active, and either it is loadable and it is loaded, or its nearest loadable ancestor is loaded, or it has no loadable ancestor; false otherwise.

Definition at line 225 of file prim.h.

bool UsdPrim::IsMaster ( ) const
inline

Return true if this prim is a master prim, false otherwise.

Definition at line 1097 of file prim.h.

bool UsdPrim::IsModel ( ) const
inline

Return true if this prim is a model based on its kind metadata, false otherwise.

Definition at line 229 of file prim.h.

USD_API bool UsdPrim::IsPseudoRoot ( ) const

Returns true if the prim is the pseudo root.

Equivalent to

USD_API void UsdPrim::Load ( UsdLoadPolicy  policy = UsdLoadWithDescendants) const

Load this prim, all its ancestors, and by default all its descendants. If loadPolicy is UsdLoadWithoutDescendants, then load only this prim and its ancestors.

See UsdStage::Load for additional details.

USD_API bool UsdPrim::RemoveProperty ( const TfToken propName)

Remove all scene description for the property with the given propName in the current UsdEditTarget. Return true if the property is removed, false otherwise.

bool UsdPrim::SetActive ( bool  active) const
inline

Author 'active' metadata for this prim at the current EditTarget.

See Usd_ActiveInactive for the effects of activating or deactivating a prim.

Definition at line 201 of file prim.h.

bool UsdPrim::SetInstanceable ( bool  instanceable) const
inline

Author 'instanceable' metadata for this prim at the current EditTarget.

Definition at line 1066 of file prim.h.

USD_API bool UsdPrim::SetPayload ( const SdfPayload payload) const
Deprecated:
Author payload metadata for this prim at the current edit target. Return true on success, false if the value could not be set.
See Also
Usd_Payloads
USD_API bool UsdPrim::SetPayload ( const std::string assetPath,
const SdfPath primPath 
) const
Deprecated:
Shorthand for SetPayload(SdfPayload(assetPath, primPath)).
USD_API bool UsdPrim::SetPayload ( const SdfLayerHandle &  layer,
const SdfPath primPath 
) const
Deprecated:
Shorthand for SetPayload(SdfPayload(layer->GetIdentifier(), primPath)).
USD_API void UsdPrim::SetPropertyOrder ( const TfTokenVector order) const

Author an opinion for propertyOrder metadata on this prim at the current EditTarget.

bool UsdPrim::SetSpecifier ( SdfSpecifier  specifier) const
inline

Author an opinion for this Prim's specifier at the current edit target.

Definition at line 167 of file prim.h.

bool UsdPrim::SetTypeName ( const TfToken typeName) const
inline

Author this Prim's typeName at the current EditTarget.

Definition at line 176 of file prim.h.

USD_API void UsdPrim::Unload ( ) const

Unloads this prim and all its descendants.

See UsdStage::Unload for additional details.

Friends And Related Function Documentation

friend class Usd_PrimData
friend

Definition at line 1182 of file prim.h.

Definition at line 1183 of file prim.h.

const PcpPrimIndex& Usd_PrimGetSourcePrimIndex ( const UsdPrim )
friend
friend class UsdAPISchemaBase
friend

Definition at line 1179 of file prim.h.

friend class UsdObject
friend

Definition at line 1174 of file prim.h.

friend struct UsdPrim_AttrConnectionFinder
friend

Definition at line 1185 of file prim.h.

friend struct UsdPrim_RelTargetFinder
friend

Definition at line 1184 of file prim.h.

friend class UsdPrimRange
friend

Definition at line 1181 of file prim.h.

Definition at line 1175 of file prim.h.

Definition at line 1176 of file prim.h.

friend class UsdProperty
friend

Definition at line 1177 of file prim.h.

friend class UsdSchemaBase
friend

Definition at line 1178 of file prim.h.

friend class UsdStage
friend

Definition at line 1180 of file prim.h.


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