Developer Forum

Marking an Asset with Python

I am trying to automate the creation of assets in a Blender file, but when I try to call bpy.ops.asset.mark() it reports “No data-block selected that supports asset operation” even though an object is selected.

I assume because this is only intended to be called from the outliner. I have tried overriding the context, but haven’t be able to figure it out.

You can reproduce this by typing:

import bpy

Into the scripting interface and running the script.

Does anyone know of a way to mark an asset using the python API?

Can confirm.

You can, however, mark an object as asset by calling its asset_mark method, like so:['my_object'].asset_mark()


I missed this in the API. Thank you so much! That is exactly what I was looking for.

1 Like

unfortunately after using “only” that command, the preview in the asset browser is missing… :frowning:

Call['my_object'].asset_generate_preview() right afterwards.

And just in case you’d like to edit asset data…['my_object'].asset_data.description['my_object'].asset_data.tags['my_object']['my_object'].asset_data.catalog_id

…might be the next things you’ll need.

1 Like

great, thank you!!!