Metadata
In this example, we will show you how to use the CreativeEditor SDK's CreativeEngine block
API to modify a block's metadata.
Metadata are a flat map of strings, that you can freely modify. They're serialized with the scene and may be used for various applications.
Setup#
This example uses the headless CreativeEngine. See the Setup article for a detailed guide.
To get started right away, you can also access the block
API within a running CE.SDK instance via cesdk.engine.block
.
Check out the APIs Overview to see that illustrated in more detail.
Functions#
setMetadata(id: DesignBlockId, key: string, value: string): void
Set a metadata value of a block identified by a key. If the key does not exist, yet, it will be added.
id
: The block whose metadata will be accessed.key
: The key used to identify the desired piece of metadata.value
: The value to set.
hasMetadata(id: DesignBlockId, key: string): boolean
Check if the block has metadata associated with the key.
id
: The block whose metadata will be accessed.key
: The key used to identify the desired piece of metadata.- Returns whether the key exists.
getMetadata(id: DesignBlockId, key: string): string
Get a metadata value of a block identified by a key. If the key does not exist, yet, this method will fail.
id
: The block whose metadata will be accessed.key
: The key used to identify the desired piece of metadata.- Returns the value associated with the key.
findAllMetadata(id: DesignBlockId): string[]
Query all metadata keys that exist on this block.
id
: The block whose metadata will be accessed.- Returns A list of all metadata keys on this block or an error, if the block is invalid.
removeMetadata(id: DesignBlockId, key: string): void
Remove metadata associated with the key from the given block. If the key does not exist, this method will fail.
id
: The block whose metadata will be accessed.key
: The key used to identify the desired piece of metadata.