From 28f81496dde5d5b2571c151e5a9d2a0797e4f970 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 30 Oct 2024 16:07:25 +0500 Subject: [PATCH] Small refactor for sync_edited_objects 1) remove materials if-branch as they're never edited 2) validate object explicitly --- src/bonsai/bonsai/bim/export_ifc.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/bonsai/bonsai/bim/export_ifc.py b/src/bonsai/bonsai/bim/export_ifc.py index 72b0baa8ec..7a2968472b 100644 --- a/src/bonsai/bonsai/bim/export_ifc.py +++ b/src/bonsai/bonsai/bim/export_ifc.py @@ -115,17 +115,12 @@ class IfcExporter: for obj in IfcStore.edited_objs.copy(): if not obj: continue - try: - if isinstance(obj, bpy.types.Material): - # TODO: do we add materials to edited_objs? - continue - else: - element = tool.Ifc.get_entity(obj) - if element: - results.append(element) - bpy.ops.bim.update_representation(obj=obj.name) - except ReferenceError: - pass # The object is likely deleted + if not tool.Blender.is_valid_data_block(obj): + continue + element = tool.Ifc.get_entity(obj) + if element: + results.append(element) + bpy.ops.bim.update_representation(obj=obj.name) IfcStore.edited_objs.clear() return results