There is no documentation on how to iterate through assets in an asset library.
I tried looking at the python scripts that deal with assets but I can’t quite understand them fully.
I’m trying to iterate over a bunch of materials and generate the previews one by one, because if I let blender do it automatically it fills all 32gb of ram of my system and crashes.
This script loops over any found assets from your asset libraries that are of type
world. You can however easily return any other blend data type by modifying the last lines in the script:
Hello ! I’m honored of having been linked on BSE Are we talking about assets in the currently opened file or in an user asset library ? If they’re in the current file, you can for example :
idx_start, idx_end = 0, 100 # That's your batch numbers
i = -1
for mat in bpy.data.materials:
if not mat.asset_data:
i += 1
if i < idx_start:
if i >= idx_end:
See the docs.
Of course you’ll need to wait long enough for all previews to generate before closing the file otherwise the unfinished previews wil be blank afterwards.