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).")
This commit is contained in:
Andrej730
2024-09-27 17:43:23 +05:00
parent 63ffa1aadb
commit 24a6ed0e5c
@@ -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()