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]
beam.asset_generate_preview()
preview = beam.preview
>>> preview
bpy.data.objects['IfcBeam/SBS-STR-AEC-Concrete:H900W950:4099546']...ImagePreview
img = create_image(beam.name, preview.image_size[0], preview.image_size[1])
img.file_format = "PNG"
img.filepath = "//beam.png"
img.save()
The asset previews are shown like below:
But the saved image is all black, like below:
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!

