Solved Getting materials from Asset browser

I am trying to get all materials from asset browser with the C++ SDK and have found the following endpoint:

However my knowledge in C++ is quite limited and I have previously only built C4D plugins in python so I am a little lost in how to use the class. I guess I need to get a instance of the interface in some way.

Does anyone have an example of how to retrieve the asset browser instance and get items from it?

Hello @krfft,

thank you for reaching out to us. And please excuse the delay, but we did decide to wait with our answer for the all new and shiny R25 release. The new R25 C++ documentation does include the first part for an Asset API Handbook which contains most of the basics, i.e., how to iterate over stuff, how to create some basic asset types and so on, other topics will be dealt with at a later point.

Some, but not all examples given there will translate directly to S24, because some parts of the Asset API have changed, as the Asset Browser is still under development. Below you will find a code snippet for finding the first ten materials in the user preferences repository which should also run under S24. Please feel free to ask follopw up questions if you have any.


// This code will iterate over the ten first materials that are contained in the user preferences
// repository, which will contain the builtin assets of Cinema 4D as well as user databases.

// The maximum number of material assets to find so that we do not saturate the console with 
// possibly thousands of materials that could be stored in the asset browser of a user.
static Int32 g_max_object_to_find = 10;
maxon::Result<void> FindAssets()
  // An error scope handling which is more verbose than a simple "iferr_scope;". If one of the
  // calls below returns an error, the function will be exited through this block.
    ApplicationOutput("Stopped FindAssets() execution with the error: @", err);
    return err;
  // Get the user preferences repository. For retrieving specific user database repositories, see 
  // CreateRepositories() in asset_api_basics_databases.cpp.
  const maxon::AssetRepositoryRef& repository = maxon::AssetInterface::GetUserPrefsRepository();
  // Now we are preparing some arguments for the call to find assets.
  // The asset type we are looking for. Asset types are declared in the maxxon::AssetTypes 
  // namespace.
  const maxon::AssetType assetType = maxon::AssetTypes::File();
  // The id of the asset we are looking for, passing an empty id will return assets with any id.
  const maxon::Id assetFindId = {};
  // The version of the asset we are looking for, passing an empty id will return assets with any 
  // version.
  const maxon::Id assetVersion = {};
  // A maxon::BaseArray where we will store all found asset descriptions. 
  maxon::BaseArray<maxon::AssetDescription> results;
  // There are multiple methods attached to AssetRepositoryInterface to find assets in an 
  // repository. We use here FindAsset() which allows us to define the verion types we want
  // to retrieve. In this case we pass ASSET_FIND_MODE::LATEST to only find the latest version of
  // each asset. But we could for example also pass ASSET_FIND_MODE::ALL to find all version of an
  // asset.
  repository.FindAssets(assetType, assetFindId, assetVersion, maxon::ASSET_FIND_MODE::LATEST, 
    results) iferr_return;
  ApplicationOutput("Total number of file-type assets found: @", results.GetCount());
  maxon::Int counter = 0;
  // Iterate over the results and print out some data for the first ten material assets.
  for (maxon::AssetDescription assetDescription : results)
    // Exit when we encountered ten object assets.
    if (counter == g_max_object_to_find)
    // We retrieve the subtype of the subtype asset. See the topic Asset API - Metadata for more 
    // details on asset metadata.
    maxon::AssetMetaData metadata = assetDescription.GetMetaData();
    maxon::Id subTypeId = metadata.Get(maxon::ASSETMETADATA::SubType) iferr_return;
    // This asset is of subtype material. 
    if (subTypeId == maxon::ASSETMETADATA::SubType_ENUM_Material)
      // Now we collect some data to print out.
      // The id of the asset itself.
      maxon::Id assetId = assetDescription.GetId();
      // Rather pointless here, because we know the repository in this case already, but an 
      // AssetDescription has a the id of the repository attached it is contained in.
      maxon::Id repositoryId = assetDescription.GetRepositoryId();
      // The storage Url of the asset.
      const maxon::Url& assetUrl = assetDescription.GetUrl() iferr_return;
      // The name of the asset.
      maxon::String assetName = assetDescription.GetMetaString(maxon::OBJECT::BASE::NAME,
        maxon::LanguageRef()) iferr_return;
      ApplicationOutput("Found object asset with the id: @", assetId);
      ApplicationOutput("\tRepository: @", repositoryId);
      ApplicationOutput("\tLocation: @", assetUrl);
      ApplicationOutput("\tName: @", assetName);
  return maxon::OK;

MAXON SDK Specialist