usdrt::UsdPrim

Defined in usdrt/scenegraph/usd/usd/impl/usd_decl.h

class UsdPrim

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.

Public Functions

bool HasAttribute(const TfToken &name) const

Check if this prim has an attribute named name in Fabric. Does not check for attribute existence in the underlying USD stage.

Parameters

name – The attribute name.

Returns

Return true if the attribute exists on this prim, and false otherwise.

UsdAttribute GetAttribute(const TfToken &name) const

Get the attribute named name if it exists in fabric. Does not check for attribute existence in the underlying USD stage.

Parameters

name – The attribute name.

Returns

Return the attribute on this prim with name name, or an invalid attribute object if not found.

std::vector<UsdAttribute> GetAttributes() const

Get all attributes on this prim.

Note

Current implementation only returns attributes that exist in Fabric

Returns

Return a vector of attributes that are on the prim.

std::vector<UsdAttribute> GetAuthoredAttributes() const

Get all authored attributes on this prim.

Returns

Return a vector of attributes that are authored on the prim.

UsdAttribute CreateAttribute(const TfToken &name, const SdfValueTypeName &typeName, bool custom = true) const

Create a new attribute on this prim in fabric.

TODO: SdfVariability parameter

Parameters
  • name – The attribute name.

  • typeName – The type of the attribute.

  • custom – Indicate if the attribute is custom. Default is true. This currently does nothing as it is not represented in fabric.

Returns

Return the new attribute.

bool HasRelationship(const TfToken &name) const

Check if this prim has a relationship named name. Fabric is the ground truth for existence, so there is no USD fallback.

Parameters

name – The relationship name.

Returns

Return true if the relationship exists on this prim, and false otherwise.

UsdRelationship GetRelationship(const TfToken &name) const

Get the relationship named name if it exists.

Note

Fabric does not yet support lists of targets for relationships.

Parameters

name – The relationship name.

Returns

Return the relationship on this prim with name name, or an invalid relationship object if not found.

std::vector<UsdRelationship> GetRelationships() const

Get all relationships on this prim.

Note

Fabric does not yet support lists of targets for relationships.

Returns

Return a vector of relationship that are on the prim.

std::vector<UsdRelationship> GetAuthoredRelationships() const

Get all authored relationships on this prim.

Note

Fabric does not yet support lists of targets for relationships.

Returns

Return a vector of relationships that are authored on the prim.

UsdRelationship CreateRelationship(const TfToken &relName, bool custom = true) const

Create a new relationship on this prim in fabric.

Parameters
  • relName – The relationship name.

  • custom – Indicate if the relationship is custom. Default is true. This currently does nothing as it is not represented in fabric.

Returns

Return the new relationship.

bool RemoveProperty(const TfToken &name) const

Remove property from this prim in fabric.

Parameters

name – Name of the property to remove.

Returns

Return true if the property was removed, and false otherwise.

TfTokenVector GetPropertyNames() const

Get all of this prim’s properties (attributes and relationships). Includes build in properties.

Returns

Return a TfTokenVector of property names.

TfTokenVector GetAuthoredPropertyNames() const

Get all of this prim’s properties (attributes and relationships). Includes build in properties.

Note: Fabric doesn’t differientiate between authored properties, so this API is here for completeness but is the exact same as GetPropertyNames.

Returns

Return a TfTokenVector of property names.

bool HasProperty(const TfToken &name) const

Check if the prim has property name.

Parameters

name – Property name

Returns

True if this prim has property name.

bool IsValid() const

Check if this is a valid prim. A prim is valid if it exists in fabric. This includes minimally populated prims.

Returns

Return true if this prim is valid, and false otherwise.

UsdStageRefPtr GetStage() const

Get the fabric stage holding this UsdPrim.

Returns

Return a pointer to the fabric stage that contains this prim.

UsdPrim GetPrim() const

UsdObject method required for UsdPrim to be a complete type.

Returns

Return this prim.

const TfToken GetName() const

Get the name of this prim.

Returns

Return the name of this prim.

SdfPath GetPath() const

Get the path to this prim.

Returns

Returns the path to this prim.

const SdfPath GetPrimPath() const

Get the path to this prim.

Returns

Returns the path to this prim.

UsdPrim GetChild(const TfToken &name) const

Get child prim name from this prim’s children.

Parameters

name – The name of the child to look for.

Returns

Return the child prim, or an invalid prim if not found.

std::vector<UsdPrim> GetChildren() const

Get child prims of this prim. If fabric population / hierarchy is active, get child prims using the fabric Connectivity API. Otherwise, fall back to GetChildren in USD and load the prims into fabric.

Returns

Return a vector containing all child prims of this prim.

TfTokenVector GetChildrenNames() const

Get list of child prim names when iterating over GetChildren.

Returns

TfTokenVector of child names.

std::vector<UsdPrim> GetAllChildren() const

Get all child prims of this prim. If fabric population / hierarchy is active, get child prims using the fabric Connectivity API. Otherwise, fall back to GetChildren USD and load the prims into fabric.

Note

This differs from USD functionality. Same as GetChildren.

Returns

Return a vector containing all child prims of this prim.

TfTokenVector GetAllChildrenNames() const

Get list of child prim names when iterating over GetAllChildren.

Returns

TfTokenVector of child names.

UsdPrim GetParent() const

Get this prim’s parent prim.

Returns

Return this prim’s parent prim.

UsdPrim GetNextSibling() const

Get this prim’s next sibling in the scene hierarchy. If population is active, get next sibling using Connectivity. Otherwise fall back to USD.

Returns

Return this prim’s next sibling if it has one. Otherwise return an invalid prim.

TfToken GetTypeName() const

Get the type name for this prim. This looks for the attribute of type SdfValueTypeNames->PrimTypeTag in fabric.

Returns

Return the prim type name.

bool SetTypeName(const TfToken &typeName) const

Set this prim’s type name. This clears any existing type name and sets the attribute SdfValueTypeNames->PrimTypeTag in fabric to typeName.

Parameters

typeName – Prim’s new type name to set.

Returns

Return true if this prim’s type name has been updated. False otherwise.

bool ClearTypeName() const

Clear this prim’s typename. This removes the attribute of type SdfValueTypeNames->PrimTypeTag from fabric.

Returns

Return true if this prim’s type name has been cleared. False otherwise.

bool HasAuthoredTypeName() const

Check if this prim has an authored typename. True if an attribute of type SdfValueTypeNames->PrimTypeTag has a value authored.

Returns

Return true if this prim’s typename tag is authored, false otherwise.

template<typename SchemaType>
inline bool IsA() const

Query if this prim’s type is or is a child type of SchemaType. An error will be issued if SchemaType is an unknown schema.

Template Parameters

SchemaType – The schema type name or alias type.

Returns

Return true if this prim is or is a child type of SchemaType.

bool IsA(const TfToken &schemaType) const

Query if this prim’s type is or is a child type of SchemaType. An error will be issued if the schemaType is an unknown schema.

Parameters

schemaType – The schema c++ type.

Returns

Return true if this prim is or is a child type of SchemaType.

bool AddAppliedSchema(const TfToken &appliedSchemaName) const

Apply schema of type appliedSchemaName. This authors an attribute of type SdfValueTypeNames->AppliedSchemaTypeTag with value appliedSchemaName. This method assumes:

  • input validation (if desired) has already been done by other API methods (UsdPrim::ApplyAPI).

  • the appliedSchemaName is the schema alias. For example: MotionAPI instead of UsdGeomMotionAPI. This is required for Fabric.

  • for multiple-apply schemas, appliedSchemaName contains both the namespace and instance name. For example: ‘CollectionAPI:myStuff’.

ApplyAPI is the preferred method for applying valid API schemas. Using ApplyAPI instead will convert schema names to alias and join namespace/instance names.

Parameters

appliedSchemaName – The full name or alias of the schema to apply.

Returns

Return true if the schema has been applied, false otherwise.

bool RemoveAppliedSchema(const TfToken &appliedSchemaName) const

Remove schema of type appliedSchemaName. This removes the attribute of type SdfValueTypeNames->AppliedSchemaTypeTag with value appliedSchemaName. This method assumes:

  • input validation has already been done by other API methods (UsdPrim::RemoveAPI).

  • the appliedSchemaName is the schema alias. For example: MotionAPI instead of UsdGeomMotionAPI. This is required for Fabric.

  • for multiple-apply schemas, appliedSchemaName contains both the namespace and instance name. For example: ‘CollectionAPI:myStuff’.

RemoveAPI is the preferred method for applying valid API schemas. Using RemoveAPI instead will convert schema names to alias and join namespace/instance names.

Parameters

appliedSchemaName – The full name or alias of the schema to remove.

Returns

Return true if the schema has been removed, false otherwise.

bool HasAPI(const TfToken &schemaIdentifier, const TfToken &instanceName = TfToken()) const

Check is this prim has a schema schemaIdentifier applied. Looks for an authored attribute of type SdfValueTypeNames->AppliedSchemaTypeTag and value schemaIdentifier. For MultipleApplyAPI schemas, the query value is schemaIdentifier as the namespace, joined with instanceName.

Parameters
  • schemaIdentifier – The full name or alias of the schema to check.

  • instanceName – If non-empy, used to determine if a particular instance of a multiple-apply api schema has been applied to the prim if SchemaType is a multiple-apply api schema. Default empty.

Returns

Return true if the schema is applied to this prim, false otherwise.

template<typename SchemaType>
inline bool HasAPI(const TfToken &instanceName = TfToken()) const

Check is this prim has a schema of type SchemaType applied. Looks for an authored attribute of type SdfValueTypeNames->AppliedSchemaTypeTag and value SchemaType.

An error will be issued if SchemaType does not a known applied API schema, or if, for a miltiple-apply API schema, instanceName is empty.

Template Parameters

SchemaType – The schema type to check.

Parameters

instanceName – If non-empy, used to determine if a particular instance of a multiple-apply api schema has been applied to the prim if SchemaType is a multiple-apply api schema. Default empty.

Returns

Return true if the schema is applied to this prim, false otherwise.

bool ApplyAPI(const TfToken &schemaIdentifier, const TfToken &instanceName = TfToken()) const

Apply schema of type schemaIdentifier to the prim.

For schemaIdentifier to be valid schema to apply, it must be a single-apply or multiple-apply api schema, and for multiple-apply, instanceName must not be empty.

Parameters
  • schemaIdentifier – The full name or alias of the schema to apply.

  • instanceName – If non-empy, used to determine if a particular instance of a multiple-apply api schema has been applied to the prim if SchemaType is a multiple-apply api schema. Default empty.

Returns

Return true if the schema has been applied, false otherwise.

template<typename SchemaType>
inline bool ApplyAPI() const

Apply schema of type SchemaType to the prim.

An error is raised for invalid SchemaType. For SchemaType to be valid schema to apply using this template, it must be a single-apply API schema.

Template Parameters

SchemaType – The schema type to apply.

Returns

Return true if the schema has been applied, false otherwise.

template<typename SchemaType>
inline bool ApplyAPI(const TfToken &instanceName) const

Apply schema of type SchemaType to the prim.

An error is raised for invalid SchemaType. For SchemaType to be valid schema to apply using this template, it must be a multiple-apply api schema and instanceName must not be empty.

Template Parameters

SchemaType – The schema type to apply.

Parameters

instanceName – If non-empy, used to determine if a particular instance of a multiple-apply api schema has been applied to the prim if SchemaType is a multiple-apply api schema.

Returns

Return true if the schema has been applied, false otherwise.

bool RemoveAPI(const TfToken &schemaIdentifier, const TfToken &instanceName = TfToken()) const

Remove schema of type schemaIdentifier.

Parameters
  • schemaIdentifier – The full name or alias of the schema to remove.

  • instanceName – If non-empy, used to remove a particular instance of a multiple-apply api schema from the prim if SchemaType is a multiple-apply api schema. Default empty.

Returns

Return true if the schema has been removed, false otherwise.

template<typename SchemaType>
inline bool RemoveAPI() const

Remove single-apply API schema of type SchemaType.

An error is raised for invalid SchemaType. For SchemaType to be valid schema to remove using this template, it must be a single apply-api schema.

Template Parameters

SchemaType – The schema type to remove.

Returns

Return true if the schema has been removed, false otherwise.

template<typename SchemaType>
inline bool RemoveAPI(const TfToken &instanceName) const

Remove multiple-apply API schema of type SchemaType.

An error is raised for invalid SchemaType. For SchemaType to be valid schema to remove using this template, it must be a multiple-apply api schema and instanceName must not be empty.

Template Parameters

SchemaType – The schema type to remove.

Parameters

instanceName – Used to remove a particular instance of a multiple-apply api schema from the prim. Must not be empty.

Returns

Return true if the schema has been removed, false otherwise.

TfTokenVector GetAppliedSchemas() const

Get all applied schemas. Look for all attributes of type SdfValueTypeNames->AppliedSchemaTypeTag.

Returns

Return a vector of applied schema alias names.

explicit operator bool() const

Check if this prim is valid. See UsdPrim::IsValid.

Returns

Return true if this prim is valid, and false otherwise.