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

This is a general purpose API schema, used to describe a collection of heterogeneous objects within the scene. More...

+ Inheritance diagram for UsdCollectionAPI:

Public Types

using MembershipQuery = UsdCollectionMembershipQuery
 

Public Member Functions

 UsdCollectionAPI (const UsdPrim &prim=UsdPrim(), const TfToken &name=TfToken())
 Construct a UsdCollectionAPI on UsdPrim prim with name name . More...
 
 UsdCollectionAPI (const UsdSchemaBase &schemaObj, const TfToken &name)
 Construct a UsdCollectionAPI on the prim held by schemaObj with name name. More...
 
virtual USD_API ~UsdCollectionAPI ()
 Destructor. More...
 
TfToken GetName () const
 Returns the name of this multiple-apply schema instance. More...
 
USD_API UsdAttribute GetExpansionRuleAttr () const
 Specifies how the paths that are included in the collection must be expanded to determine its members. More...
 
USD_API UsdAttribute CreateExpansionRuleAttr (VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
 See GetExpansionRuleAttr(), and also Create vs Get Property Methods for when to use Get vs Create. More...
 
USD_API UsdAttribute GetIncludeRootAttr () const
 Boolean attribute indicating whether the pseudo-root path </> should be counted as one of the included target paths. More...
 
USD_API UsdAttribute CreateIncludeRootAttr (VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
 See GetIncludeRootAttr(), and also Create vs Get Property Methods for when to use Get vs Create. More...
 
USD_API UsdRelationship GetIncludesRel () const
 Specifies a list of targets that are included in the collection. More...
 
USD_API UsdRelationship CreateIncludesRel () const
 See GetIncludesRel(), and also Create vs Get Property Methods for when to use Get vs Create. More...
 
USD_API UsdRelationship GetExcludesRel () const
 Specifies a list of targets that are excluded below the included paths in this collection. More...
 
USD_API UsdRelationship CreateExcludesRel () const
 See GetExcludesRel(), and also Create vs Get Property Methods for when to use Get vs Create. More...
 
USD_API SdfPath GetCollectionPath () const
 Returns the canonical path that represents this collection. More...
 
USD_API
UsdCollectionMembershipQuery 
ComputeMembershipQuery () const
 Computes and returns a UsdCollectionMembershipQuery object which can be used to query inclusion or exclusion of paths in the collection. More...
 
USD_API void ComputeMembershipQuery (UsdCollectionMembershipQuery *query) const
 Populates the UsdCollectionMembershipQuery object with data from this collection, so it can be used to query inclusion or exclusion of paths. More...
 
USD_API bool HasNoIncludedPaths () const
 Returns true if the collection has nothing included in it. More...
 
USD_API bool Validate (std::string *reason) const
 Validates the collection by checking the following rules: More...
 
USD_API bool ResetCollection () const
 Resets the collection by clearing both the includes and excludes targets of the collection in the current UsdEditTarget. More...
 
USD_API bool BlockCollection () const
 Blocks the targets of the includes and excludes relationships of the collection, making it <* empty if "includeRoot" is false (or unset) or. More...
 
Collection Authoring API

Convenience API for adding or removing prims and properties to (or from) a collection..

USD_API bool IncludePath (const SdfPath &pathToInclude) const
 Includes or adds the given path, pathToInclude in the collection. More...
 
USD_API bool ExcludePath (const SdfPath &pathToExclude) const
 Excludes or removes the given path, pathToExclude from the collection. More...
 
- Public Member Functions inherited from UsdAPISchemaBase
 UsdAPISchemaBase (const UsdPrim &prim=UsdPrim())
 Construct a UsdAPISchemaBase on UsdPrim prim . More...
 
 UsdAPISchemaBase (const UsdSchemaBase &schemaObj)
 Construct a UsdAPISchemaBase on the prim held by schemaObj . More...
 
virtual USD_API ~UsdAPISchemaBase ()=0
 Destructor. More...
 
- 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. More...
 
bool IsTyped () const
 Returns whether or not this class inherits from UsdTyped. More...
 
bool IsAPISchema () const
 Returns whether this is an API schema or not. More...
 
bool IsAppliedAPISchema () const
 Returns whether this is an applied API schema or not. More...
 
bool IsMultipleApplyAPISchema () const
 Returns whether this is an applied API schema or not. More...
 
UsdSchemaType GetSchemaType () const
 
USD_API UsdSchemaBase (const UsdPrim &prim=UsdPrim())
 Construct and store prim as the held prim. More...
 
USD_API UsdSchemaBase (const UsdSchemaBase &otherSchema)
 Construct and store for the same prim held by otherSchema. More...
 
virtual USD_API ~UsdSchemaBase ()
 Destructor. More...
 
USD_API operator bool () const
 Return true if this schema object is compatible with its held prim, false otherwise. More...
 
UsdPrim GetPrim () const
 Return this schema object's held prim. More...
 
SdfPath GetPath () const
 Shorthand for GetPrim()->GetPath(). More...
 
USD_API SdfPrimSpecHandle GetSchemaClassPrimDefinition () const
 Return the prim definition associated with this schema instance if one exists, otherwise return null. More...
 

Static Public Member Functions

static USD_API const
TfTokenVector
GetSchemaAttributeNames (bool includeInherited=true, const TfToken instanceName=TfToken())
 Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes for a given instance name. More...
 
static USD_API UsdCollectionAPI Get (const UsdStagePtr &stage, const SdfPath &path)
 Return a UsdCollectionAPI holding the prim adhering to this schema at path on stage. More...
 
static USD_API UsdCollectionAPI Get (const UsdPrim &prim, const TfToken &name)
 Return a UsdCollectionAPI with name name holding the prim prim. More...
 
static USD_API bool IsSchemaPropertyBaseName (const TfToken &baseName)
 Checks if the given name baseName is the base name of a property of CollectionAPI. More...
 
static USD_API bool IsCollectionAPIPath (const SdfPath &path, TfToken *name)
 Checks if the given path path is of an API schema of type CollectionAPI. More...
 
static USD_API UsdCollectionAPI ApplyCollection (const UsdPrim &prim, const TfToken &name, const TfToken &expansionRule=UsdTokens->expandPrims)
 Adds a new collection named name on the given prim, prim with the specified expansion-rule, expansionRule. More...
 
static USD_API UsdCollectionAPI GetCollection (const UsdStagePtr &stage, const SdfPath &collectionPath)
 Returns the collection represented by the given collection path, collectionPath on the given USD stage. More...
 
static USD_API UsdCollectionAPI GetCollection (const UsdPrim &prim, const TfToken &name)
 Returns the schema object representing a collection named name on the given prim. More...
 
static USD_API std::vector
< UsdCollectionAPI
GetAllCollections (const UsdPrim &prim)
 Returns all the named collections on the given USD prim. More...
 
static USD_API SdfPath GetNamedCollectionPath (const UsdPrim &prim, const TfToken &collectionName)
 Returns the canonical path to the collection named, name on the given prim, prim. More...
 
static USD_API std::set
< UsdObject
ComputeIncludedObjects (const UsdCollectionMembershipQuery &query, const UsdStageWeakPtr &stage, const Usd_PrimFlagsPredicate &pred=UsdPrimDefaultPredicate)
 Returns all the usd objects that satisfy the predicate, pred in the collection represented by the UsdCollectionMembershipQuery object, query. More...
 
static USD_API SdfPathSet ComputeIncludedPaths (const UsdCollectionMembershipQuery &query, const UsdStageWeakPtr &stage, const Usd_PrimFlagsPredicate &pred=UsdPrimDefaultPredicate)
 Returns all the paths that satisfy the predicate, pred in the collection represented by the UsdCollectionMembershipQuery object, query. More...
 
- Static Public Member Functions inherited from UsdAPISchemaBase
static USD_API const
TfTokenVector
GetSchemaAttributeNames (bool includeInherited=true)
 Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes. More...
 
- Static Public Member Functions inherited from UsdSchemaBase
static const TfTokenVectorGetSchemaAttributeNames (bool includeInherited=true)
 

Static Public Attributes

static const UsdSchemaType schemaType = UsdSchemaType::MultipleApplyAPI
 Compile time constant representing what kind of schema this class is. More...
 
- Static Public Attributes inherited from UsdAPISchemaBase
static const UsdSchemaType schemaType = UsdSchemaType::AbstractBase
 Compile time constant representing what kind of schema this class is. More...
 
- Static Public Attributes inherited from UsdSchemaBase
static const UsdSchemaType schemaType = UsdSchemaType::AbstractBase
 Compile time constant representing what kind of schema this class is. More...
 

Protected Member Functions

USD_API UsdSchemaType _GetSchemaType () const override
 Returns the type of schema this class belongs to. More...
 
- Protected Member Functions inherited from UsdAPISchemaBase
 UsdAPISchemaBase (const UsdPrim &prim, const TfToken &instanceName)
 Construct a multiple-apply UsdAPISchemaBase on UsdPrim prim with the specified instanceName. More...
 
 UsdAPISchemaBase (const UsdSchemaBase &schemaObj, const TfToken &instanceName)
 Construct a multiple-apply UsdAPISchemaBase on the prim held by schemaObj with the given instanceName. More...
 
const TfToken_GetInstanceName () const
 Returns the instance name of the API schema object belonging to a multiple-apply API schema. More...
 
USD_API bool _IsCompatible () const override
 Check whether this APISchema object is valid for the currently held prim. More...
 
- Protected Member Functions inherited from UsdSchemaBase
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
 

Additional Inherited Members

- Static Protected Member Functions inherited from UsdAPISchemaBase
template<typename APISchemaType >
static APISchemaType _ApplyAPISchema (const UsdPrim &prim, const TfToken &apiSchemaName)
 Helper method to apply a single-apply API schema with the given schema name apiSchemaName' and C++ type 'APISchemaType'. More...
 
template<typename APISchemaType >
static APISchemaType _MultipleApplyAPISchema (const UsdPrim &prim, const TfToken &apiSchemaName, const TfToken &instanceName)
 Helper method to apply a multiple-apply API schema with the given schema name apiSchemaName', C++ type 'APISchemaType' and instance name instanceName. More...
 

Detailed Description

This is a general purpose API schema, used to describe a collection of heterogeneous objects within the scene.

"Objects" here may be prims or properties belonging to prims or other collections. It's an add-on schema that can be applied many times to a prim with different collection names.

A collection allows an enumeration of a set of paths to include and a set of paths to exclude. Whether the descendants of an included path are members of a collection are decided by its expansion rule (see below). If the collection excludes paths that are not descendents of included paths, the collection implicitly includes the root path </>. If such a collection also includes paths that are not descendants of the excluded paths, it is considered invalid, since the intention is ambiguous.

All the properties authored by the schema are namespaced under "collection:". The given name of the collection provides additional namespacing for the various per-collection properties, which include the following:

  • uniform token collection:collectionName:expansionRule - specified how the paths that are included in the collection must be expanded to determine its members. Possible values include:
    • explicitOnly - only paths in the includes rel targets and not in the excludes rel targets belong to the collection.
    • expandPrims - all the prims at or below the includes rel- targets (and not under the excludes rel-targets) belong to the collection. Any property paths included in the collection would, of course, also be honored. This is the default behavior as it satisfies most use cases.
    • expandPrimsAndProperties - like expandPrims, but also includes all properties on all matched prims. We're still not quite sure what the use cases are for this, but you can use it to capture a whole lot of UsdObjects very concisely.
  • bool collection:collectionName:includeRoot - boolean attribute indicating whether the pseudo-root path </> should be counted as one of the included target paths. The fallback is false. This separate attribute is required because relationships cannot directly target the root.
  • rel collection:collectionName:includes - specifies a list of targets that are included in the collection. This can target prims or properties directly. A collection can insert the rules of another collection by making its includes relationship target the collection:{collectionName} property on the owning prim of the collection to be included. Such a property may not (and typically does not) exist on the UsdStage, but it is the path that is used to refer to the collection. It is important to note that including another collection does not guarantee the contents of that collection will be in the final collection; instead, the rules are merged. This means, for example, an exclude entry may exclude a portion of the included collection. When a collection includes one or more collections, the order in which targets are added to the includes relationship may become significant, if there are conflicting opinions about the same path. Targets that are added later are considered to be stronger than earlier targets for the same path.
  • rel collection:collectionName:excludes - specifies a list of targets that are excluded below the included paths in this collection. This can target prims or properties directly, but cannot target another collection. This is to keep the membership determining logic simple, efficient and easier to reason about. Finally, it is invalid for a collection to exclude paths that are not included in it. The presence of such "orphaned" excluded paths will not affect the set of paths included in the collection, but may affect the performance of querying membership of a path in the collection (see UsdCollectionAPI::MembershipQuery::IsPathIncluded) or of enumerating the objects belonging to the collection (see UsdCollectionAPI::GetIncludedObjects).

Implicit inclusion

In some scenarios it is useful to express a collection that includes everything except certain paths. To support this, a collection that has an exclude that is not a descendent of any include will include the root path </>.

Creating collections in C++

For any described attribute Fallback Value or Allowed Values below that are text/tokens, the actual token is published and defined in UsdTokens. So to set an attribute to the value "rightHanded", use UsdTokens->rightHanded as the value.

Definition at line 152 of file collectionAPI.h.

Constructor & Destructor Documentation

UsdCollectionAPI ( const UsdPrim prim = UsdPrim(),
const TfToken name = TfToken() 
)
inlineexplicit

Construct a UsdCollectionAPI on UsdPrim prim with name name .

Equivalent to UsdCollectionAPI::Get( prim.GetStage(), prim.GetPath().AppendProperty( "collection:name"));

for a valid prim, but will not immediately throw an error for an invalid prim

Definition at line 169 of file collectionAPI.h.

UsdCollectionAPI ( const UsdSchemaBase schemaObj,
const TfToken name 
)
inlineexplicit

Construct a UsdCollectionAPI on the prim held by schemaObj with name name.

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

Definition at line 178 of file collectionAPI.h.

virtual USD_API ~UsdCollectionAPI ( )
virtual

Destructor.

Member Function Documentation

USD_API UsdSchemaType _GetSchemaType ( ) const
overrideprotectedvirtual

Returns the type of schema this class belongs to.

See Also
UsdSchemaType

Reimplemented from UsdAPISchemaBase.

static USD_API UsdCollectionAPI ApplyCollection ( const UsdPrim prim,
const TfToken name,
const TfToken expansionRule = UsdTokens->expandPrims 
)
static

Adds a new collection named name on the given prim, prim with the specified expansion-rule, expansionRule.

If a collection named name already exists, its expansion-rule is updated with the provided value and it is returned.

The name of a collection, name may itself be namespaced, to facilitate organization of collections into groups. However, the base-name of a collection (i.e. the last component of the collection name) should not be the same as one of the core collection schema properties, i.e. should not be 'expansionRule' or 'includes' or 'excludes'.

USD_API bool BlockCollection ( ) const

Blocks the targets of the includes and excludes relationships of the collection, making it <* empty if "includeRoot" is false (or unset) or.

  • include everything if "includeRoot" is true. (assuming there are no opinions in stronger edit targets).
static USD_API std::set<UsdObject> ComputeIncludedObjects ( const UsdCollectionMembershipQuery query,
const UsdStageWeakPtr &  stage,
const Usd_PrimFlagsPredicate &  pred = UsdPrimDefaultPredicate 
)
static

Returns all the usd objects that satisfy the predicate, pred in the collection represented by the UsdCollectionMembershipQuery object, query.

The results depends on the load state of the UsdStage, stage.

static USD_API SdfPathSet ComputeIncludedPaths ( const UsdCollectionMembershipQuery query,
const UsdStageWeakPtr &  stage,
const Usd_PrimFlagsPredicate &  pred = UsdPrimDefaultPredicate 
)
static

Returns all the paths that satisfy the predicate, pred in the collection represented by the UsdCollectionMembershipQuery object, query.

The result depends on the load state of the UsdStage, stage.

USD_API UsdCollectionMembershipQuery ComputeMembershipQuery ( ) const

Computes and returns a UsdCollectionMembershipQuery object which can be used to query inclusion or exclusion of paths in the collection.

USD_API void ComputeMembershipQuery ( UsdCollectionMembershipQuery query) const

Populates the UsdCollectionMembershipQuery object with data from this collection, so it can be used to query inclusion or exclusion of paths.

USD_API UsdRelationship CreateExcludesRel ( ) const

See GetExcludesRel(), and also Create vs Get Property Methods for when to use Get vs Create.

USD_API UsdAttribute CreateExpansionRuleAttr ( VtValue const &  defaultValue = VtValue(),
bool  writeSparsely = false 
) const

See GetExpansionRuleAttr(), and also Create vs Get Property Methods for when to use Get vs Create.

If specified, author defaultValue as the attribute's default, sparsely (when it makes sense to do so) if writeSparsely is true - the default for writeSparsely is false.

USD_API UsdAttribute CreateIncludeRootAttr ( VtValue const &  defaultValue = VtValue(),
bool  writeSparsely = false 
) const

See GetIncludeRootAttr(), and also Create vs Get Property Methods for when to use Get vs Create.

If specified, author defaultValue as the attribute's default, sparsely (when it makes sense to do so) if writeSparsely is true - the default for writeSparsely is false.

USD_API UsdRelationship CreateIncludesRel ( ) const

See GetIncludesRel(), and also Create vs Get Property Methods for when to use Get vs Create.

USD_API bool ExcludePath ( const SdfPath pathToExclude) const

Excludes or removes the given path, pathToExclude from the collection.

If the collection is empty, the collection becomes one that includes all paths except the givne path. Otherwise, this does nothing if the path is not included in the collection.

This does not modify the expansion-rule of the collection. Hence, if the expansionRule is expandPrims or expandPrimsAndProperties, then the descendants of pathToExclude will also be excluded from the collection, unless explicitly included.

See Also
UsdCollectionAPI::IncludePath()
static USD_API UsdCollectionAPI Get ( const UsdStagePtr &  stage,
const SdfPath path 
)
static

Return a UsdCollectionAPI 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. path must be of the format <path>.collection:name .

This is shorthand for the following:

* TfToken name = SdfPath::StripNamespace(path.GetToken());
* stage->GetPrimAtPath(path.GetPrimPath()), name);
*
static USD_API UsdCollectionAPI Get ( const UsdPrim prim,
const TfToken name 
)
static

Return a UsdCollectionAPI with name name holding the prim prim.

Shorthand for UsdCollectionAPI(prim, name);

static USD_API std::vector<UsdCollectionAPI> GetAllCollections ( const UsdPrim prim)
static

Returns all the named collections on the given USD prim.

static USD_API UsdCollectionAPI GetCollection ( const UsdStagePtr &  stage,
const SdfPath collectionPath 
)
static

Returns the collection represented by the given collection path, collectionPath on the given USD stage.

static USD_API UsdCollectionAPI GetCollection ( const UsdPrim prim,
const TfToken name 
)
static

Returns the schema object representing a collection named name on the given prim.

USD_API SdfPath GetCollectionPath ( ) const

Returns the canonical path that represents this collection.

This points to a property named "collection:{collectionName}" on the prim defining the collection (which won't really exist as a property on the UsdStage, but will be used to refer to the collection). This is the path to be used to "include" this collection in another collection.

USD_API UsdRelationship GetExcludesRel ( ) const

Specifies a list of targets that are excluded below the included paths in this collection.

This can target prims or properties directly, but cannot target another collection. This is to keep the membership determining logic simple, efficient and easier to reason about. Finally, it is invalid for a collection to exclude paths that are not included in it. The presence of such "orphaned" excluded paths will not affect the set of paths included in the collection, but may affect the performance of querying membership of a path in the collection (see UsdCollectionAPI::MembershipQuery::IsPathIncluded) or of enumerating the objects belonging to the collection (see UsdCollectionAPI::GetIncludedObjects).

USD_API UsdAttribute GetExpansionRuleAttr ( ) const

Specifies how the paths that are included in the collection must be expanded to determine its members.

Declaration uniform token expansionRule = "expandPrims"
C++ Type TfToken
Usd Type SdfValueTypeNames->Token
Variability SdfVariabilityUniform
Allowed Values explicitOnly, expandPrims, expandPrimsAndProperties
USD_API UsdAttribute GetIncludeRootAttr ( ) const

Boolean attribute indicating whether the pseudo-root path </> should be counted as one of the included target paths.

The fallback is false. This separate attribute is required because relationships cannot directly target the root.

Declaration uniform bool includeRoot
C++ Type bool
Usd Type SdfValueTypeNames->Bool
Variability SdfVariabilityUniform
USD_API UsdRelationship GetIncludesRel ( ) const

Specifies a list of targets that are included in the collection.

This can target prims or properties directly. A collection can insert the rules of another collection by making its includes relationship target the collection:{collectionName} property on the owning prim of the collection to be included

TfToken GetName ( ) const
inline

Returns the name of this multiple-apply schema instance.

Definition at line 198 of file collectionAPI.h.

static USD_API SdfPath GetNamedCollectionPath ( const UsdPrim prim,
const TfToken collectionName 
)
static

Returns the canonical path to the collection named, name on the given prim, prim.

See Also
GetCollectionPath()
static USD_API const TfTokenVector& GetSchemaAttributeNames ( bool  includeInherited = true,
const TfToken  instanceName = TfToken() 
)
static

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

Does not include attributes that may be authored by custom/extended methods of the schemas involved. The names returned will have the proper namespace prefix.

USD_API bool HasNoIncludedPaths ( ) const

Returns true if the collection has nothing included in it.

This requires both that the includes relationship have no target paths, and that the includeRoot attribute be false. Note that there may be cases where the collection has no objects included in it even when HasNoIncludedPaths() returns false. For example, if the included objects are unloaded or if the included objects are also excluded.

USD_API bool IncludePath ( const SdfPath pathToInclude) const

Includes or adds the given path, pathToInclude in the collection.

This does nothing if the path is already included in the collection.

This does not modify the expansion-rule of the collection. Hence, if the expansionRule is expandPrims or expandPrimsAndProperties, then the descendants of pathToInclude will be also included in the collection unless explicitly excluded.

See Also
UsdCollectionAPI::ExcludePath()
static USD_API bool IsCollectionAPIPath ( const SdfPath path,
TfToken name 
)
static

Checks if the given path path is of an API schema of type CollectionAPI.

If so, it stores the instance name of the schema in name and returns true. Otherwise, it returns false.

static USD_API bool IsSchemaPropertyBaseName ( const TfToken baseName)
static

Checks if the given name baseName is the base name of a property of CollectionAPI.

USD_API bool ResetCollection ( ) const

Resets the collection by clearing both the includes and excludes targets of the collection in the current UsdEditTarget.

Note
This does not modify the "includeRoot" attribute which is used to include or exclude everything (i.e. the pseudoRoot) in the USD stage.
USD_API bool Validate ( std::string *  reason) const

Validates the collection by checking the following rules:

  • a collection's expansionRule should be one of "explicitOnly", "expandPrims" or "expandPrimsAndProperties".
  • a collection should not have have a circular dependency on another collection.
  • a collection should not have both includes and excludes among its top-level rules

Member Data Documentation

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

See Also
UsdSchemaType

Definition at line 158 of file collectionAPI.h.


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