Bonsai - improve error message if ifc file fails to open #5694

This commit is contained in:
Andrej730
2024-11-06 17:50:58 +05:00
parent 4fdb313449
commit 681b89d95c
@@ -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