diff --git a/src/bonsai/bonsai/bim/ifc.py b/src/bonsai/bonsai/bim/ifc.py index ae680ea15a..4cbdeb0982 100644 --- a/src/bonsai/bonsai/bim/ifc.py +++ b/src/bonsai/bonsai/bim/ifc.py @@ -112,6 +112,7 @@ class IfcStore: if IfcStore.path: try: IfcStore.load_file(IfcStore.path) + tool.Ifc.after_file_loaded() except Exception as e: print(f"Failed to load file {IfcStore.path}. Error details: {e}") return IfcStore.file @@ -201,6 +202,7 @@ class IfcStore: IfcStore.file = ifcopenshell.open(path, should_stream=True) else: IfcStore.file = ifcopenshell.open(path) + tool.Ifc.after_file_loaded() @staticmethod def get_schema() -> ifcopenshell.ifcopenshell_wrapper.schema_definition: diff --git a/src/bonsai/bonsai/bim/module/project/operator.py b/src/bonsai/bonsai/bim/module/project/operator.py index 72d86b4196..259f65fc0a 100644 --- a/src/bonsai/bonsai/bim/module/project/operator.py +++ b/src/bonsai/bonsai/bim/module/project/operator.py @@ -154,7 +154,6 @@ class CreateProject(bpy.types.Operator): core.create_project( tool.Ifc, tool.Georeference, tool.Project, tool.Spatial, schema=props.export_schema, template=template ) - bonsai.bim.schema.reload(tool.Ifc.get().schema_identifier) tool.Blender.register_toolbar() def rollback(self, data): @@ -1072,7 +1071,6 @@ class LoadProjectElements(bpy.types.Operator): def execute(self, context): self.props = tool.Project.get_project_props() self.file = tool.Ifc.get() - bonsai.bim.schema.reload(self.file.schema_identifier) start = time.time() logger = logging.getLogger("ImportIFC") path_log = tool.Blender.get_data_dir_path("process.log") diff --git a/src/bonsai/bonsai/tool/ifc.py b/src/bonsai/bonsai/tool/ifc.py index 7f4b14bc02..70095d8d19 100644 --- a/src/bonsai/bonsai/tool/ifc.py +++ b/src/bonsai/bonsai/tool/ifc.py @@ -26,6 +26,7 @@ import ifcopenshell.util.element import ifcopenshell.util.schema import bonsai.core.tool import bonsai.bim.handler +import bonsai.bim.schema import bonsai.tool as tool from pathlib import Path from bonsai.bim.ifc import IfcStore, IFC_CONNECTED_TYPE @@ -61,11 +62,17 @@ class Ifc(bonsai.core.tool.Ifc): @classmethod def set(cls, ifc: ifcopenshell.file) -> None: IfcStore.file = ifc + cls.after_file_loaded() @classmethod def get(cls) -> ifcopenshell.file: return IfcStore.get_file() + @classmethod + def after_file_loaded(cls) -> None: + assert IfcStore.file + bonsai.bim.schema.reload(IfcStore.file.schema_identifier) + @classmethod def set_path(cls, value: str) -> None: bim_props = tool.Blender.get_bim_props()