Metadata#
What is Metadata?#
Metadata in OpenUSD refers to a set of name-value pairs that provide additional, non-animatable information attached to prims or their properties. The concept is similar to properties, but it allows us to add custom information or annotations to scene description elements via a dictionary without modifying the underlying schema or data model.
How Does It Work?#
Metadata is stored separately from the primary data and can be accessed and modified independently. It is typically used to store additional information that is not directly related to the geometry or rendering of an object, such as:
Author information
Creation/modification dates
Project-specific data
Annotations or notes
Rendering hints or flags
Metadata can be set at different levels of the scene hierarchy, allowing for both global and localized metadata.
While both metadata and attributes allow us to store additional data, there are some key differences:
Metadata is separate from the core schema and data model, while attributes are part of the schema definition.
Metadata is typically used for supplementary information, while attributes are often used for data directly related to the object’s properties or behavior.
Metadata cannot be sampled over time (i.e. timesamples), allowing it to be evaluated and stored more efficiently than attribute values.
Working With Python#
Here are a few ways we can interact with metadata via the Python API:
1# Retrieve the metadata value associated with the given key for a USD Object
2usdobject.GetMetadata('key')
3
4# Set the metadata value for the given key on a USD Object
5usdobject.SetMetadata('key', value)
6
7# Retrieve the metadata value associated with the given key for the stage
8stage.GetMetadata('key')
9
10# Set the metadata value for the given key on the stage
11stage.SetMetadata('key', value)
12
13# Use for better performance if accessing a single value and not all the metadata within a key
14GetMetadataByDictKey()
It’s worth noting that key
will typically be either assetInfo
, which can be used to set asset related data or customData
, which can be used for everything else. We can also create additional metadata keys by adding a new schema.
Key Takeaways#
The metadata API in OpenUSD provides a flexible way to store and access additional information about prims and attributes through a dictionary, without modifying the core schema or data model. While metadata and custom attributes serve different purposes, understanding their differences and appropriate use cases is essential for effective scene description and data management in OpenUSD.