UNSOLVED Loading materials/meshes from Asset Browser (Cinema 4D R25) from Python

Hi,
As a part of an automated system, I load required materials and assets, when preparing the first version of a scene, from the Content Browser (Cinema 4D R23), using simple Python code (below, for materials)

def LoadMaterial(location, name):
    doc = c4d.documents.GetActiveDocument()
    location = "preset://" + location + "/" + name
    status = c4d.documents.MergeDocument(doc, location, c4d.SCENEFILTER_MATERIALS)
    return status

As I understand the Content Browser have been replaced by Asset Browser, which looks much more powerful and I can't wait to start using it 🙂 I can import all the assets from lib4d into R25 and access them manually, but I really need is the ability to load the assets from a code, as I do in r23. What's the best way of doing that? Can you provide me with a code snippet?

I basically want to have the same ability as in R23, wherein r25 I can pass DB name (or full path), together with object/mat name, and be able to download it to the scene. Also - is there a way to list all versions of an object or materials, and then choose one to download?

Best regards,
Tomasz

Hello @futurium,

thank you for reaching out to us. The Asset API has unfortunately not been exposed to Python yet. We are working on it, and it will be released with one of the upcoming major releases. The C++ API is already available, but only partially documented right now. Its documentation is currently worked on too and will also be updated with one of the major upcoming releases.

Finally, regarding your sentence 'I can pass DB name (or full path), together with object/mat name': The Asset API works differently than the old Content Browser, as it is more fundamentally a (collection of) database(s) and not just a repository of files. The Asset API intentionally abstracts the physical view of one of its databases. So, when you have the database with the path //user/documents/my_database, you cannot search by the paths that are inside that my_database directory, as the Asset API introduces virtual folders which are called categories and assets themselves. You can search by the URL of an asset, which then will of course reflect your local path, e.g., //user/documents/my_database/some_asset_hash/1/asset.c4d. The Asset API manages assets for you, and you are not meant to manually manage an asset location inside that database.

The database topic of the Asset API C++ documentation already contains some information on the physical vs logical data model of the Asset API.

Cheers,
Ferdinand

Hi Ferdinand,

Thank you for the explanation. Real shame the Asset API has not been exposed to Python yet. I'll wait till it's done and fully documented - let's hope it will be soon.

Best regards,
Tomasz