mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
Add error catching to model loading and let users hide error dialog
This commit is contained in:
@@ -103,6 +103,7 @@ classes = [
|
|||||||
operator.BIM_OT_select_object,
|
operator.BIM_OT_select_object,
|
||||||
operator.BIM_OT_show_description,
|
operator.BIM_OT_show_description,
|
||||||
operator.ClippingPlaneCutWithCappings,
|
operator.ClippingPlaneCutWithCappings,
|
||||||
|
operator.CloseError,
|
||||||
operator.EditBlenderCollection,
|
operator.EditBlenderCollection,
|
||||||
operator.FileAssociate,
|
operator.FileAssociate,
|
||||||
operator.FileUnassociate,
|
operator.FileUnassociate,
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import bpy
|
|||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import traceback
|
||||||
import subprocess
|
import subprocess
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
@@ -674,19 +675,23 @@ class LoadProject(bpy.types.Operator, IFCFileSelector):
|
|||||||
return self.finish_loading_project(context)
|
return self.finish_loading_project(context)
|
||||||
|
|
||||||
def finish_loading_project(self, context):
|
def finish_loading_project(self, context):
|
||||||
if not self.is_existing_ifc_file():
|
try:
|
||||||
return {"FINISHED"}
|
if not self.is_existing_ifc_file():
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
if tool.Blender.is_default_scene():
|
if tool.Blender.is_default_scene():
|
||||||
for obj in bpy.data.objects:
|
for obj in bpy.data.objects:
|
||||||
bpy.data.objects.remove(obj)
|
bpy.data.objects.remove(obj)
|
||||||
|
|
||||||
context.scene.BIMProperties.ifc_file = self.get_filepath()
|
context.scene.BIMProperties.ifc_file = self.get_filepath()
|
||||||
context.scene.BIMProjectProperties.is_loading = True
|
context.scene.BIMProjectProperties.is_loading = True
|
||||||
context.scene.BIMProjectProperties.total_elements = len(tool.Ifc.get().by_type("IfcElement"))
|
context.scene.BIMProjectProperties.total_elements = len(tool.Ifc.get().by_type("IfcElement"))
|
||||||
tool.Blender.register_toolbar()
|
tool.Blender.register_toolbar()
|
||||||
if not self.is_advanced:
|
if not self.is_advanced:
|
||||||
bpy.ops.bim.load_project_elements()
|
bpy.ops.bim.load_project_elements()
|
||||||
|
except:
|
||||||
|
blenderbim.last_error = traceback.format_exc()
|
||||||
|
raise
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
|
|||||||
@@ -90,6 +90,15 @@ class OpenUri(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
class CloseError(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.close_error"
|
||||||
|
bl_label = "Close Error"
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
blenderbim.last_error = None
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class SelectURIAttribute(bpy.types.Operator):
|
class SelectURIAttribute(bpy.types.Operator):
|
||||||
bl_idname = "bim.select_uri_attribute"
|
bl_idname = "bim.select_uri_attribute"
|
||||||
bl_label = "Select URI Attribute"
|
bl_label = "Select URI Attribute"
|
||||||
|
|||||||
@@ -406,7 +406,9 @@ class BIM_PT_tabs(Panel):
|
|||||||
|
|
||||||
if blenderbim.last_error:
|
if blenderbim.last_error:
|
||||||
box = self.layout.box()
|
box = self.layout.box()
|
||||||
box.label(text="BlenderBIM experienced an error :(", icon="ERROR")
|
row = box.row(align=True)
|
||||||
|
row.label(text="BlenderBIM experienced an error :(", icon="ERROR")
|
||||||
|
row.operator("bim.close_error", text="", icon="CANCEL")
|
||||||
box.label(text="View the console for full logs.", icon="CONSOLE")
|
box.label(text="View the console for full logs.", icon="CONSOLE")
|
||||||
box.operator("bim.copy_debug_information", text="Copy Error Message To Clipboard")
|
box.operator("bim.copy_debug_information", text="Copy Error Message To Clipboard")
|
||||||
op = box.operator("bim.open_uri", text="How Can I Fix This?")
|
op = box.operator("bim.open_uri", text="How Can I Fix This?")
|
||||||
|
|||||||
Reference in New Issue
Block a user