I want to export asset previews as images. I borrowed some codes from Blender 3.0: Is there a way to quickly create thumbnails for material and object assets? and this github page. I first created previews for assets, then created images of the previews, and finally saved the images, like below:

import bpy
from asset_browser_utilities.module.preview.tool import create_image

assets = [o for o in bpy.data.objects if o.asset_data]
>>> assets
[bpy.data.objects['IfcBeam/SBS-STR-AEC-Concrete:H900W950:4099546'], bpy.data.objects['IfcColumn/COL-STR-AEC-Concrete:W1200H1400:4099287']]

beam = assets[0]
preview = beam.preview
>>> preview

img = create_image(beam.name, preview.image_size[0], preview.image_size[1])
img.file_format = "PNG"
img.filepath = "//beam.png"

The asset previews are shown like below:

enter image description here

But the saved image is all black, like below:

enter image description here

The file is here. I think the asset previews show that the previews have been created successfully. Then why the exported images would become black? How to solve this? Thank you!


1 Answer 1


I just found this great tool to meet my need of exporting previews as images in batch! But I am still wondering about the reasons about this black bug using the codes by myself...

  • $\begingroup$ Hello ! I'm the author of this addon. :) The reason is that the preview generation is asynchronous (to not block the interface while generating) and takes a bit of time to complete, so if you try to save the image right in the next line of code, the data doesn't have enough time to be generated. You can add a bit of time buffer with application timers usually 1 second is enough ,but it can take more if it's a material or a complex mesh $\endgroup$
    – Gorgious
    Commented Sep 20, 2022 at 14:07
  • $\begingroup$ @Gorgious I see! Thank you very much for your explanation, and the awesome addon! :) $\endgroup$
    – Howie
    Commented Sep 21, 2022 at 2:16
  • $\begingroup$ Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. $\endgroup$
    – TheLabCat
    Commented Sep 21, 2022 at 4:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .