mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:32:37 +00:00
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:
committed by
GitHub
parent
01b1b57f71
commit
2f84c188f5
@@ -143,19 +143,29 @@ class AuthoringData:
|
|||||||
obj = new_obj
|
obj = new_obj
|
||||||
obj.asset_mark()
|
obj.asset_mark()
|
||||||
obj.asset_generate_preview()
|
obj.asset_generate_preview()
|
||||||
icon_id = obj.preview.icon_id
|
|
||||||
if ifc_class not in cls.data["preview_constr_types"]:
|
def wait_for_asset_previews_generation(check_interval_seconds=0.03):
|
||||||
cls.data["preview_constr_types"][ifc_class] = {}
|
if bpy.app.is_job_running("RENDER_PREVIEW"):
|
||||||
cls.data["preview_constr_types"][ifc_class][str(relating_type_id)] = {"icon_id": icon_id, "object": obj}
|
print(f"{obj.name}: Generating preview...")
|
||||||
if to_be_deleted:
|
return check_interval_seconds
|
||||||
element = tool.Ifc.get_entity(obj)
|
else:
|
||||||
if element:
|
icon_id = obj.preview.icon_id
|
||||||
tool.Ifc.delete(element)
|
if ifc_class not in cls.data["preview_constr_types"]:
|
||||||
tool.Ifc.unlink(obj=obj)
|
cls.data["preview_constr_types"][ifc_class] = {}
|
||||||
# We do not delete the object from the scene, as that breaks Blender's asset system.
|
cls.data["preview_constr_types"][ifc_class][str(relating_type_id)] = {"icon_id": icon_id, "object": obj}
|
||||||
# Instead, we only "hide" it by unlinking it from all collections.
|
if to_be_deleted:
|
||||||
for collection in obj.users_collection:
|
element = tool.Ifc.get_entity(obj)
|
||||||
collection.objects.unlink(obj)
|
if element:
|
||||||
|
tool.Ifc.delete(element)
|
||||||
|
tool.Ifc.unlink(obj=obj)
|
||||||
|
# We do not delete the object from the scene, as that breaks Blender's asset system.
|
||||||
|
# Instead, we only "hide" it by unlinking it from all collections.
|
||||||
|
for collection in obj.users_collection:
|
||||||
|
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):
|
||||||
|
|||||||
Reference in New Issue
Block a user