Solved How to obtain the path of a selected Asset in Asset Browser

I'm trying to script in Cinema 4D and I want to access the path of an Asset that's currently selected in the Asset Browser. I'm familiar with retrieving the path of an Asset, but I'm not quite sure how to identify or get the Asset that's actively selected by the user.
Could anyone guide me on this, or share a code snippet that achieves this?

Thanks for any help!

Hello @Easan,

Thank you for reaching out to us. What you want to do is not possible, as there is no way to retrieve the selected asset(s) in "the" Asset Browser. For once because we tend to not expose UIs and their functionalities and because there can be many Asset Browser instances in Cinema 4D. And these instances do not share selection states, so the state is not stored in the asset itself (wich then loops back to the fact that we do not expose UIs).

What you can do is:

  • Just use drag and drop. This is the preferred method. I just yesterday made a posting on how to manually handle asset drag drop events (at the example of a tree view, would work similarly in other cases where you have access to drag and drop data). But in most cases, you won't have to do all that, because things like text fields and filename fields have already built in asset drag and drop support. So, you can just add them to your UI and start using them.
  • Open your own Asset Browser popup to let the user select an asset, using maxon.AssetManagerInterface.OpenPopup. See the example at the end of this posting for details.



"""Demonstrates how to let a user select one or multiple assets with an asset browser popup.

import c4d
import maxon

doc: c4d.documents.BaseDocument  # The active document

def OnAssetSelect(data: maxon.DragAndDropDataAssetArray) -> None:
    """Called by the maxon.AssetManagerInterface.OpenPopup call below once the user finalizes his
    or her selection.
    asset: maxon.AssetDescriptionInterface
    url: maxon.Url

    # Iterate over each selected asset ...
    for asset, url, _ in data.GetAssetDescriptions():
        aid: maxon.Id = asset.GetId()
        repo: maxon.AssetRepositoryRef = asset.GetRepository()
        name: str = asset.GetMetaString(
            maxon.OBJECT.BASE.NAME, maxon.Resource.GetCurrentLanguage(), "")
        # ... and print some metadata for it.
        print (f"{name = }, {aid = }, {url = }, {repo = }")

def main() -> None:
        title="Select textures to load",

if __name__ == '__main__':

MAXON SDK Specialist

Thank you very much for your help, your code has been extremely useful to me.