Fix bim tool crash (#2445)

* Attempt to wait for assets (triggers infinite loop)

* Using timer instead of sleep

* remove sleep import
This commit is contained in:
Carlos Villagrasa
2022-09-27 17:31:59 +02:00
committed by GitHub
parent 01b1b57f71
commit 2f84c188f5
@@ -143,6 +143,12 @@ class AuthoringData:
obj = new_obj obj = new_obj
obj.asset_mark() obj.asset_mark()
obj.asset_generate_preview() obj.asset_generate_preview()
def wait_for_asset_previews_generation(check_interval_seconds=0.03):
if bpy.app.is_job_running("RENDER_PREVIEW"):
print(f"{obj.name}: Generating preview...")
return check_interval_seconds
else:
icon_id = obj.preview.icon_id icon_id = obj.preview.icon_id
if ifc_class not in cls.data["preview_constr_types"]: if ifc_class not in cls.data["preview_constr_types"]:
cls.data["preview_constr_types"][ifc_class] = {} cls.data["preview_constr_types"][ifc_class] = {}
@@ -156,6 +162,10 @@ class AuthoringData:
# Instead, we only "hide" it by unlinking it from all collections. # Instead, we only "hide" it by unlinking it from all collections.
for collection in obj.users_collection: for collection in obj.users_collection:
collection.objects.unlink(obj) collection.objects.unlink(obj)
print(f"{obj.name}: Preview generated!")
return None
bpy.app.timers.register(wait_for_asset_previews_generation)
@classmethod @classmethod
def assetize_relating_type_from_selection(cls, browser=False): def assetize_relating_type_from_selection(cls, browser=False):