Asset browser - automate marking assets

i want to batch mark a bunch of materials as assets using python. right now the only process i can see is done though bpy.ops.asset.mark() operator in the outliner on a clicked material data block. i can automate the operator to run in outliner via a custom context, but i can’t figure out how to get it to target a specific material data block.

is this just too early days of asset browser to consider automation?

1 Like

Did you find a solution to this?

sadly i haven’t been investigating the asset browser any further lately, but hopefully some functionality eventually surfaces for this!

1 Like

After a bit of messing around I found “asset_mark()” and “asset_clear()”

Here are some examples (you can use .asset_mark() and .asset_clear() on loads of other things, these are just a few):

bpy.data.objects[0].asset_mark()
bpy.data.meshes[0].asset_mark()
bpy.data.materials[0].asset_mark()
bpy.data.textures[0].asset_mark()

Replace .asset_mark() with .asset_clear() in the above examples to unmark assets.

You can very easily mark all your materials as assets by doing this:

for mat in bpy.data.materials:
        mat.asset_mark()
4 Likes

i made a small addon with this functionality. It requires blender 3

4 Likes

Nice, i used this functionality in my addon “assetlibrarytools”, which also let’s you unmark all assets

1 Like

I added options to mark Assets in all blend file that is contained in a specified Asset library.
This will run each blend file from the command line and mark the assets so please be aware that there is potential danger.

there are some issues i noticed:

  1. if you add a new Asset Library you need to do a Script reload to get it to show for processing.
  2. The thumbnails are missing somehow and will need some investigation.
1 Like

I’m developping an addon to do just that, and with working automatic previews. You can check it out there : Batch mark assets and generate previews from library files