From 24a6ed0e5c9de5b706b307009e194930574f18c4 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 27 Sep 2024 17:43:23 +0500 Subject: [PATCH] Show an error if library file schema is not compatible with the current file Example - https://i.imgur.com/t1gxBJ4.png ("Schema of library file (IFC4X3_ADD2) is not compatible with the current IFC file (IFC4).") --- src/bonsai/bonsai/bim/module/project/operator.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/bonsai/bonsai/bim/module/project/operator.py b/src/bonsai/bonsai/bim/module/project/operator.py index 4b926c7a7f..19fc16c010 100644 --- a/src/bonsai/bonsai/bim/module/project/operator.py +++ b/src/bonsai/bonsai/bim/module/project/operator.py @@ -160,8 +160,17 @@ class SelectLibraryFile(bpy.types.Operator, IFCFileSelector): def _execute(self, context): filepath = self.get_filepath() + ifc_file = tool.Ifc.get() + library_file = ifcopenshell.open(filepath) + if library_file.schema_identifier != ifc_file.schema_identifier: + self.report( + {"ERROR"}, + f"Schema of library file ({library_file.schema_identifier}) is not compatible with the current IFC file ({ifc_file.schema_identifier}).", + ) + return {"CANCELLED"} + IfcStore.library_path = filepath - IfcStore.library_file = ifcopenshell.open(filepath) + IfcStore.library_file = library_file bpy.ops.bim.refresh_library() if context.area: context.area.tag_redraw()