Loading...
Searching...
No Matches
UsdCollectionAPI Class Reference

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

#include <collectionAPI.h>

+ 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 .
 
 UsdCollectionAPI (const UsdSchemaBase &schemaObj, const TfToken &name)
 Construct a UsdCollectionAPI on the prim held by schemaObj with name name.
 
virtual USD_API ~UsdCollectionAPI ()
 Destructor.
 
TfToken GetName () const
 Returns the name of this multiple-apply schema instance.
 
USD_API UsdAttribute GetExpansionRuleAttr () const
 Specifies how the paths that are included in the collection must be expanded to determine its members.
 
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.
 
USD_API UsdAttribute GetIncludeRootAttr () const
 Boolean attribute indicating whether the pseudo-root path </> should be counted as one of the included target paths.
 
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.
 
USD_API UsdAttribute GetMembershipExpressionAttr () const
 Specifies a path expression that determines membership in this collection.
 
USD_API UsdAttribute CreateMembershipExpressionAttr (VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
 See GetMembershipExpressionAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
 
USD_API UsdAttribute GetCollectionAttr () const
 This property represents the collection for the purpose of allowing another collection to include it.
 
USD_API UsdAttribute CreateCollectionAttr (VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
 See GetCollectionAttr(), and also Create vs Get Property Methods for when to use Get vs Create.
 
USD_API UsdRelationship GetIncludesRel () const
 Specifies a list of targets that are included in the collection.
 
USD_API UsdRelationship CreateIncludesRel () const
 See GetIncludesRel(), and also Create vs Get Property Methods for when to use Get vs Create.
 
USD_API UsdRelationship GetExcludesRel () const
 Specifies a list of targets that are excluded below the included paths in this collection.
 
USD_API UsdRelationship CreateExcludesRel () const
 See GetExcludesRel(), and also Create vs Get Property Methods for when to use Get vs Create.
 
USD_API SdfPath GetCollectionPath () const
 Returns the canonical path that represents this collection.
 
USD_API SdfPathExpression ResolveCompleteMembershipExpression () const
 Obtain a complete SdfPathExpression from this collection's membershipExpression.
 
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 bool HasNoIncludedPaths () const
 Returns true if the collection has nothing included in it.
 
USD_API bool Validate (std::string *reason) const
 Validates the collection by checking the following rules:
 
USD_API bool ResetCollection () const
 Resets the collection by clearing both the includes and excludes targets of the collection in the current UsdEditTarget.
 
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.
 
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.
 
USD_API bool ExcludePath (const SdfPath &pathToExclude) const
 Excludes or removes the given path, pathToExclude from the collection.
 
- 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 TfTokenVector GetSchemaAttributeNames (bool includeInherited, const TfToken &instanceName)
 Return a vector of names of all pre-declared attributes for this schema class and all its ancestor classes for a given instance name.
 
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.
 
static USD_API UsdCollectionAPI Get (const UsdPrim &prim, const TfToken &name)
 Return a UsdCollectionAPI with name name holding the prim prim.
 
static USD_API std::vector< UsdCollectionAPIGetAll (const UsdPrim &prim)
 Return a vector of all named instances of UsdCollectionAPI on the given prim.
 
static USD_API bool IsSchemaPropertyBaseName (const TfToken &baseName)
 Checks if the given name baseName is the base name of a property of CollectionAPI.
 
static USD_API bool IsCollectionAPIPath (const SdfPath &path, TfToken *name)
 Checks if the given path path is of an API schema of type CollectionAPI.
 
static USD_API bool CanApply (const UsdPrim &prim, const TfToken &name, std::string *whyNot=nullptr)
 Returns true if this multiple-apply API schema can be applied, with the given instance name, name, to the given prim.
 
static USD_API UsdCollectionAPI Apply (const UsdPrim &prim, const TfToken &name)
 Applies this multiple-apply API schema to the given prim along with the given instance name, name.
 
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.
 
static USD_API UsdCollectionAPI GetCollection (const UsdPrim &prim, const TfToken &name)
 Returns the schema object representing a collection named name on the given prim.
 
static USD_API std::vector< UsdCollectionAPIGetAllCollections (const UsdPrim &prim)
 Returns all the named collections on the given USD prim.
 
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.
 
static USD_API SdfPathExpression ResolveCompleteMembershipExpression (SdfPathExpression pathExpr, UsdPrim const &prim)
 
static USD_API std::set< UsdObjectComputeIncludedObjects (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.
 
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.
 
static USD_API bool CanContainPropertyName (const TfToken &name)
 Test whether a given name contains the "collection:" prefix.
 
- 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::MultipleApplyAPI
 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.
 
- 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
 

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

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. When expansionRule is explicitOnly, this attribute is ignored.
  • 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 (see UsdCollectionAPI::GetCollectionAttr). 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).
  • uniform opaque collection:collectionName - opaque attribute (meaning it can never have a value) that represents the collection for the purpose of allowing another collection to include it. When this property is targeted by another collection's includes relationship, the rules of this collection will be inserted into the rules of the collection that includes it.

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++

bool ApplyCollections(UsdPrim const &prim)
{
/* Assuming the folling prim hierarchy:
|- Vehicles
| |- FourWheelers
| | |- CarA
| | |- CarB
| | |- CarC
| | |- CarD
| | |- TruckA
| | |- TruckB
| |- TwoWheelers
| | |- BikeA
| | |- BikeB
| | |- BicycleA
| | |- FrontWheel
| | |- BackWheel
| |- Other
| | |- TricycleA
| | |- FrontWheel
| | |- BackWheels
*/
// Create a collection that includes only the cars, by adding all
// of "FourWheelers" and excluding the trucks.
cars.CreateIncludesRel().AddTarget(SdfPath("/Vehicles/FourWheelers"));
cars.CreateExcludesRel().AddTarget(SdfPath("/Vehicles/FourWheelers/TruckA"));
cars.CreateExcludesRel().AddTarget(SdfPath("/Vehicles/FourWheelers/TruckB"));
// Create a collection that includes only the bikes by explicitly inluding
// just the two bikes in the collection.
UsdCollectionAPI bikes = UsdCollectionAPI::Apply(prim, "bikes");
bikes.CreateExpansionRuleAttr(VtValue(UsdTokens->explicitOnly));
bikes.CreateIncludesRel().AddTarget(SdfPath("/Vehicles/TwoWheelers/BikeA"));
bikes.CreateIncludesRel().AddTarget(SdfPath("/Vehicles/TwoWheelers/BikeB"));
// Create an explicit collection of slow-moving vehicles.
// An explicit collection implies that descendants (i.e. the front and back
// wheels) are not considered to be included in the collection.
UsdCollectionAPI slowVehicles = UsdCollectionAPI::Apply(prim, "slowVehicles");
slowVehicles.CreateExpansionRuleAttr(VtValue(UsdTokens->explicitOnly));
slowVehicles.CreateIncludesRel().AddTarget(SdfPath("/Vehicles/TwoWheelers/BicycleA"));
slowVehicles.CreateIncludesRel().AddTarget(SdfPath("/Vehicles/Other/TricycleA"));
UsdCollectionAPI vehicles = UsdCollectionAPI::Apply(prim, "vehicles");
vehicles.CreateIncludesRel().AddTarget(slowVehicles.GetCollectionPath());
vehicles.CreateIncludesRel().AddTarget(SdfPath("/Vehicles/FourWheelers/TruckA"));
vehicles.CreateIncludesRel().AddTarget(SdfPath("/Vehicles/FourWheelers/TruckB"));
// CarA is included in the 'vehicles' collection through the 'cars' collection.
TF_AXIOM(query.IsPathIncluded("/Vehicles/FourWheelers/CarA"))
// BikeB is included in the 'vehicles' collection through the 'cars' collection.
TF_AXIOM(query.IsPathIncluded("/Vehicles/TwoWheelers/BikeB"))
// BikeB is included directly in the 'vehicles' collection
TF_AXIOM(query.IsPathIncluded("/Vehicles/FourWheelers/TruckA"))
// BicycleA is included, but it's descendants are not, since it is part of
// an "explicitOnly" collection.
TF_AXIOM(query.IsPathIncluded("/Vehicles/TwoWheelers/BicycleA"))
TF_AXIOM(!query.IsPathIncluded("/Vehicles/TwoWheelers/BicycleA/FrontWheel"))
// TricycleA is included, but it's descendants are not, since it is part of
// an "explicitOnly" collection.
TF_AXIOM(query.IsPathIncluded("/Vehicles/Other/TricycleA"))
TF_AXIOM(!query.IsPathIncluded("/Vehicles/Other/TricycleA/BackWheels"))
SdfPathSet includedPaths;
UsdCollectionAPI::ComputeIncludedPaths(query, prim.GetStage(),
&includedPaths);
std::set<UsdObject> includedObjects;
UsdCollectionAPI::ComputeIncludedObjects(query, prim.GetStage(),
&includedObjects);
}
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
This is a general purpose API schema, used to describe a collection of heterogeneous objects within t...
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.
static USD_API UsdCollectionAPI Apply(const UsdPrim &prim, const TfToken &name)
Applies this multiple-apply API schema to the given prim along with the given instance name,...
USD_API SdfPath GetCollectionPath() const
Returns the canonical path that represents this collection.
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 Usd...
USD_API UsdCollectionMembershipQuery ComputeMembershipQuery() const
Computes and returns a UsdCollectionMembershipQuery object which can be used to query inclusion or ex...
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 UsdCollec...
USD_API UsdRelationship CreateIncludesRel() const
See GetIncludesRel(), and also Create vs Get Property Methods for when to use Get vs Create.
Represents a flattened view of a collection.
Base class for Usd scenegraph objects, providing common API.
Definition: object.h:132
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:134
USD_API bool AddTarget(const SdfPath &target, UsdListPosition position=UsdListPositionBackOfPrependList) const
Adds target to the list of targets, in the position specified by position.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:164
#define TF_AXIOM(cond)
Aborts if the condition cond is not met.
Definition: diagnostic.h:210
STL namespace.
USD_API TfStaticData< UsdTokensType > UsdTokens
A global variable with static, efficient TfTokens for use in all public USD API.

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 159 of file collectionAPI.h.

Member Typedef Documentation

◆ MembershipQuery

Definition at line 532 of file collectionAPI.h.

Constructor & Destructor Documentation

◆ UsdCollectionAPI() [1/2]

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 176 of file collectionAPI.h.

◆ UsdCollectionAPI() [2/2]

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 185 of file collectionAPI.h.

◆ ~UsdCollectionAPI()

virtual USD_API ~UsdCollectionAPI ( )
virtual

Destructor.

Member Function Documentation

◆ _GetSchemaKind()

USD_API UsdSchemaKind _GetSchemaKind ( ) const
overrideprotectedvirtual

Returns the kind of schema this class belongs to.

See also
UsdSchemaKind

Reimplemented from UsdAPISchemaBase.

◆ Apply()

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

Applies this multiple-apply API schema to the given prim along with the given instance name, name.

This information is stored by adding "CollectionAPI:<i>name</i>" to the token-valued, listOp metadata apiSchemas on the prim. For example, if name is 'instance1', the token 'CollectionAPI:instance1' is added to 'apiSchemas'.

Returns
A valid UsdCollectionAPI object is returned upon success. An invalid (or empty) UsdCollectionAPI object is returned upon failure. See UsdPrim::ApplyAPI() for conditions resulting in failure.
See also
UsdPrim::GetAppliedSchemas()
UsdPrim::HasAPI()
UsdPrim::CanApplyAPI()
UsdPrim::ApplyAPI()
UsdPrim::RemoveAPI()

◆ BlockCollection()

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).

◆ CanApply()

static USD_API bool CanApply ( const UsdPrim prim,
const TfToken name,
std::string *  whyNot = nullptr 
)
static

Returns true if this multiple-apply API schema can be applied, with the given instance name, name, to the given prim.

If this schema can not be a applied the prim, this returns false and, if provided, populates whyNot with the reason it can not be applied.

Note that if CanApply returns false, that does not necessarily imply that calling Apply will fail. Callers are expected to call CanApply before calling Apply if they want to ensure that it is valid to apply a schema.

See also
UsdPrim::GetAppliedSchemas()
UsdPrim::HasAPI()
UsdPrim::CanApplyAPI()
UsdPrim::ApplyAPI()
UsdPrim::RemoveAPI()

◆ CanContainPropertyName()

static USD_API bool CanContainPropertyName ( const TfToken name)
static

Test whether a given name contains the "collection:" prefix.

◆ ComputeIncludedObjects()

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.

◆ ComputeIncludedPaths()

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.

◆ ComputeMembershipQuery() [1/2]

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.

◆ ComputeMembershipQuery() [2/2]

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.

◆ CreateCollectionAttr()

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

See GetCollectionAttr(), 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.

◆ CreateExcludesRel()

USD_API UsdRelationship CreateExcludesRel ( ) const

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

◆ CreateExpansionRuleAttr()

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.

◆ CreateIncludeRootAttr()

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.

◆ CreateIncludesRel()

USD_API UsdRelationship CreateIncludesRel ( ) const

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

◆ CreateMembershipExpressionAttr()

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

See GetMembershipExpressionAttr(), 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.

◆ ExcludePath()

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()

◆ Get() [1/2]

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);

◆ Get() [2/2]

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 SDF_API std::string StripNamespace(const std::string &name)
Returns name stripped of any namespaces.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88

◆ GetAll()

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

Return a vector of all named instances of UsdCollectionAPI on the given prim.

◆ GetAllCollections()

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

Returns all the named collections on the given USD prim.

Deprecated:
Use GetAll(prim) instead.

◆ GetCollection() [1/2]

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.

◆ GetCollection() [2/2]

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.

◆ GetCollectionAttr()

USD_API UsdAttribute GetCollectionAttr ( ) const

This property represents the collection for the purpose of allowing another collection to include it.

When this property is targeted by another collection's includes relationship, the rules of this collection will be inserted into the rules of the collection that includes it.

Declaration uniform opaque __INSTANCE_NAME__
C++ Type SdfOpaqueValue
Usd Type SdfValueTypeNames->Opaque
Variability SdfVariabilityUniform

◆ GetCollectionPath()

USD_API SdfPath GetCollectionPath ( ) const

Returns the canonical path that represents this collection.

This points to the property named "collection:{collectionName}" on the prim defining the collection. This is the path to be used to "include" this collection in another collection.

See also
GetCollectionAttr()

◆ GetExcludesRel()

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).

◆ GetExpansionRuleAttr()

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

◆ GetIncludeRootAttr()

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

◆ GetIncludesRel()

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

◆ GetMembershipExpressionAttr()

USD_API UsdAttribute GetMembershipExpressionAttr ( ) const

Specifies a path expression that determines membership in this collection.

Declaration uniform pathExpression membershipExpression
C++ Type SdfPathExpression
Usd Type SdfValueTypeNames->PathExpression
Variability SdfVariabilityUniform

◆ GetName()

TfToken GetName ( ) const
inline

Returns the name of this multiple-apply schema instance.

Definition at line 211 of file collectionAPI.h.

◆ GetNamedCollectionPath()

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()

◆ GetSchemaAttributeNames() [1/2]

static USD_API TfTokenVector GetSchemaAttributeNames ( bool  includeInherited,
const TfToken instanceName 
)
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.

◆ GetSchemaAttributeNames() [2/2]

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.

◆ HasNoIncludedPaths()

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.

◆ IncludePath()

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()

◆ IsCollectionAPIPath()

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.

◆ IsSchemaPropertyBaseName()

static USD_API bool IsSchemaPropertyBaseName ( const TfToken baseName)
static

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

◆ ResetCollection()

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.

◆ ResolveCompleteMembershipExpression()

USD_API SdfPathExpression ResolveCompleteMembershipExpression ( ) const

Obtain a complete SdfPathExpression from this collection's membershipExpression.

First, UsdAttribute::Get() the value of GetMembershipExpressionAttr(), then resolve any contained references. Replace any remaining "weaker" references (_) with SdfPathExpression::Nothing(). Replace other references by recursively resolving the expressions from the collections on the referenced prims. If no such prims or no such collections exist, replace those references with SdfPathExpression::Nothing() as well.

◆ Validate()

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

Friends And Related Function Documentation

◆ UsdSchemaRegistry

friend class UsdSchemaRegistry
friend

Definition at line 311 of file collectionAPI.h.

Member Data Documentation

◆ schemaKind

const UsdSchemaKind schemaKind = UsdSchemaKind::MultipleApplyAPI
static

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

See also
UsdSchemaKind

Definition at line 165 of file collectionAPI.h.


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