From 400ebf2efbd8ac3392f676901d202ce6a08406f8 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 27 Sep 2024 18:01:17 +0500 Subject: [PATCH] bim.append_inspected_linked_element to ensure linked file schema is compatible --- src/bonsai/bonsai/bim/module/project/operator.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/project/operator.py b/src/bonsai/bonsai/bim/module/project/operator.py index 19fc16c010..e8bbcc76c7 100644 --- a/src/bonsai/bonsai/bim/module/project/operator.py +++ b/src/bonsai/bonsai/bim/module/project/operator.py @@ -1888,12 +1888,21 @@ class AppendInspectedLinkedElement(AppendLibraryElement): return {"CANCELLED"} queried_obj = context.scene.BIMProjectProperties.queried_obj - ifc_file = ifcopenshell.open(queried_obj["ifc_filepath"]) - element_to_append = ifc_file.by_guid(guid) + + ifc_file = tool.Ifc.get() + linked_ifc_file = ifcopenshell.open(queried_obj["ifc_filepath"]) + if ifc_file.schema_identifier != linked_ifc_file.schema_identifier: + self.report( + {"ERROR"}, + f"Schema of linked file ({linked_ifc_file.schema_identifier}) is not compatible with the current IFC file ({ifc_file.schema_identifier}).", + ) + return {"CANCELLED"} + + element_to_append = linked_ifc_file.by_guid(guid) element = ifcopenshell.api.run( "project.append_asset", tool.Ifc.get(), - library=ifc_file, + library=linked_ifc_file, element=element_to_append, ) self.import_product_from_ifc(element, context)