Skip to content

Commit

Permalink
Wait for previews to finish generating
Browse files Browse the repository at this point in the history
  • Loading branch information
jlampel committed Mar 9, 2023
1 parent a6b95a5 commit bc59fb3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


import bpy

import time

def actually_export(export_scene, filepath):
# Set the export scene as the active scene
Expand Down Expand Up @@ -82,10 +82,16 @@ def export_blend_objects(context, export_settings):
export_collection.objects.link(ob)
elif export_settings["export_as_collection"] == False and export_settings["mark_asset"]:
ob.asset_mark()
ob.asset_generate_preview()

# If exporting as a collection and marking as an asset, only mark the collection as an asset
if export_settings["export_selected"] and export_settings["export_as_collection"] and export_settings["mark_asset"]:
export_collection.asset_mark()
export_collection.asset_generate_preview()

# Temporary hack to give the preview time to generate.
# Ideally, we would wait until preview.image_size[0] != 0
time.sleep(0.5)

actually_export(export_scene, export_settings["filepath"])

Expand Down

0 comments on commit bc59fb3

Please sign in to comment.