Access and manage asset databases that contain assets which are exposed by the Asset Browser.
Asset API assets are managed by databases and multiple asset databases can be connected to a running Cinema 4D instance. The databases are organized in and accessed through repositories, always containing at least the metadata for the assets stored in it. Assets within a database are being identified with an unique identifier. The primary data for an asset, e.g., the texture file for an texture asset, can either reside or inside or outside of the database. The asset API makes formally no distinction between such local and remote assets and hides away that difference with the Url of an asset. See Asset API Assets for details on the Asset API asset model. Asset databases also contain caches for their data like preview thumbnails, downloaded content and more things, but they usually do not have to be handled manually.
The logical interface for asset databases are asset repositories which provide access to assets stored within databases. Repositories can represent one or multiple databases and allow either read and write access or read access only. An asset repository can have multiple bases, which are references to other repositories, and thereby access content from these other repositories. There are three important repositories provided by Cinema 4D which bundle data up in such fashion: The builtin repository which contains the assets that are built into Cinema 4D, the application repository which contains all assets contained in the shipped databases and the preferences repository which contains all preferences databases. Each scene document can also have its own repository which is being loaded and stored with that scene file.
An asset database is represented by an AssetDatabaseStruct which carries little information besides the Url of the database and if the database is active or not. An asset is handled on the database level as a StoreAssetStruct and as a FileAssetInterface. The former is required to store assets manually within an asset repository and the latter is the interface for a physical part of a database like a folder or file. See Asset API Assets for more information on asset representation and simplified asset creation.
The entry point to access databases is realized with the interface AssetDataBasesInterface, granting access to databases, repositories and caches that represent the current state of the asset databases attached to the running Cinema 4D instance. The important builtin, application and preferences repositories can be accessed through three static functions attached to AssetInterface. Note that the builtin and application repository are read only, while the preferences repository grants read and write access.
Repositories are represented by the interface AssetRepositoryInterface, providing means to read and write data, add versions to and access metadata for assets. See Asset API Metadata for details on asset metadata and versioning. Repositories also provide the ability to react to read, write and update events on the databases they do manage. This is realized through multiple MAXON_OBSERVABLE that are attached to AssetRepositoryInterface, allowing for actions on database events to be delegated to an arbitrary amount of user defined callback functions. See Observables for more information on the topic of observables.
Articles | Asset API | Provide content as reusable assets served with the Cinema 4D Asset Browser. |
Interface Basics | The interface system of the MAXON API is a toolset to define public APIs and to hide implementation details. It is the base for most components of the MAXON API. | |
Observables | An observable is a registry that can store references to multiple functions. These functions will be called if a certain event associated with the observable occurs. | |
API Entities | AssetDataBasesInterface | Provides helper functions to register asset repositories. |
AssetDatabaseStruct | Not yet documented | |
AssetInterface | Represents digital content which can be managed by an asset repository. | |
AssetManagerInterface | Provides limited control over the Asset Manager. | |
AssetRepositoryInterface | Provides access to a set of assets. | |
StoreAssetStruct | Not yet documented | |
UpdatableAssetRepositoryInterface | Not yet documented
| |
SDK Plugins | Asset API Basics | Showcases basic interactions with the Asset API to modify asset databases and their content. |
Common Tasks | Access User Databases | Access the data structures that represent the user asset databases attached to the running Cinema 4D instance. |
Create User Repositories | Create repositories and their underlying databases from scratch or wrap with repositories around existing user databases. | |
Access Important Repositories | Accesses the important built-in, app, preferences and active document repositories. | |
Add User Databases | Add user databases to make their assets accessible both in the Asset Browser and the Asset API. | |
Remove User Databases | Remove user databases to make their assets inaccessible both in the Asset Browser and the Asset API. | |
Activate User Databases | Activate user databases to make their assets visible both in the Asset Browser and the Asset API. | |
Deactivate User Databases | Deactivate user databases to make their assets invisible both in the Asset Browser and the Asset API. | |
Search for Assets | Find assets in repositories and filter the results by their type, subtype or other properties. | |
React to Database Events | Not yet documented |
Access the data structures that represent the user asset databases attached to the running Cinema 4D instance.
Will access and iterate over all AssetDatabaseStruct instances that represent user databases. AssetDatabaseStruct do only hold metadata about the databases they represent and not their content. Accessed will be the user databases, not the application databases with which Cinema does deliver its default assets. See Access Important Repositories for how to access the repositories of the application databases. This snippet can be found in a compileable context in the SDK plugin Asset API Basics.
Create repositories and their underlying databases from scratch or wrap with repositories around existing user databases.
The example will first create repository interfaces for all existing user databases and then open a file dialog to create a repository and its underlying database from scratch. After that it will iterate over these repositories and print out some basic information attached to them. See Access Important Repositories for how to access the application repositories. This snippet can be found in a compileable context in the SDK plugin Asset API Basics.
Accesses the important built-in, app, preferences and active document repositories.
This snippet can be found in a compileable context in the SDK plugin Asset API Basics.
Add user databases to make their assets accessible both in the Asset Browser and the Asset API.
This example will open a directory selection dialog to let the user select a database location. If the selected directory already does contain an asset database, Cinema will wrap around that data. If it does not, Cinema will create the necessary data representing a new database within this directory. It aligns closely with what is being done in the database field of the Asset Browser section of the Preferences dialog of Cinema 4D. This snippet can be found in a compileable context in the SDK plugin Asset API Basics.
Remove user databases to make their assets inaccessible both in the Asset Browser and the Asset API.
This example will remove the first user database from the running Cinema 4D instance and will cause all assets contained in the database to become inaccessible. It aligns closely with what is being done in the database field of the Asset Browser section of the Preferences dialog of Cinema 4D. This snippet can be found in a compileable context in the SDK plugin Asset API Basics.
Activate user databases to make their assets visible both in the Asset Browser and the Asset API.
The example will activate the first user database that is mounted an inactive. Activated databases will appear as checked in the database selection of the Asset Browser section of the Cinema 4D Preferences dialog. This snippet can be found in a compileable context in the SDK plugin Asset API Basics.
Deactivate user databases to make their assets invisible both in the Asset Browser and the Asset API.
The example will deactivate the first user database that is mounted an active. Deactivated databases will appear as unchecked in the database selection of the Asset Browser section of the Cinema 4D Preferences dialog. This snippet can be found in a compileable context in the SDK plugin Asset API Basics.
Search for assets in repositories and filter the results by their type, subtype or other properties.
The example iterates over the first ten object assets in the user preferences repository and prints out their name, id and the id of the repository they are contained in. This snippet can be found in a compileable context in the SDK plugin Asset API Basics.