From 681b89d95cd0578eeec69bd27124da4d118efe4f Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 6 Nov 2024 17:50:58 +0500 Subject: [PATCH] Bonsai - improve error message if ifc file fails to open #5694 --- src/bonsai/bonsai/bim/module/project/operator.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/project/operator.py b/src/bonsai/bonsai/bim/module/project/operator.py index 1aac2b0231..0e2d194545 100644 --- a/src/bonsai/bonsai/bim/module/project/operator.py +++ b/src/bonsai/bonsai/bim/module/project/operator.py @@ -763,8 +763,9 @@ class LoadProject(bpy.types.Operator, IFCFileSelector): def finish_loading_project(self, context): try: + filepath = self.get_filepath() if not self.is_existing_ifc_file(): - self.report({"ERROR"}, f"Couldn't find IFC file: '{self.get_filepath()}'.") + self.report({"ERROR"}, f"Couldn't find IFC file: '{filepath}'.") return {"FINISHED"} if self.should_start_fresh_session and tool.Blender.is_default_scene(): @@ -775,7 +776,13 @@ class LoadProject(bpy.types.Operator, IFCFileSelector): if not self.is_advanced and not self.should_start_fresh_session: bpy.ops.bim.convert_to_blender() - context.scene.BIMProperties.ifc_file = self.get_filepath() + context.scene.BIMProperties.ifc_file = filepath + if not (ifc_file := tool.Ifc.get()): + self.report( + {"ERROR"}, + f"Error loading IFC file from filepath '{filepath}'. See logs above in the system console for the details.", + ) + return {"CANCELLED"} context.scene.BIMProjectProperties.is_loading = True context.scene.BIMProjectProperties.total_elements = len(tool.Ifc.get().by_type("IfcElement")) context.scene.BIMProjectProperties.use_relative_project_path = self.use_relative_path