New create shape debugging tool to help determine broken or crashing elements

This commit is contained in:
Dion Moult
2021-02-04 22:25:43 +11:00
parent 384d007770
commit 5f8e77c292
3 changed files with 31 additions and 0 deletions
@@ -3,6 +3,7 @@ from . import ui, prop, operator
classes = (
operator.ProfileImportIFC,
operator.CreateAllShapes,
operator.CreateShapeFromStepId,
operator.SelectHighPolygonMeshes,
operator.InspectFromStepId,
@@ -21,6 +21,33 @@ class ProfileImportIFC(bpy.types.Operator):
return {"FINISHED"}
class CreateAllShapes(bpy.types.Operator):
bl_idname = "bim.create_all_shapes"
bl_label = "Create All Shapes"
def execute(self, context):
self.file = IfcStore.get_file()
elements = self.file.by_type("IfcElement") + self.file.by_type("IfcSpace")
total = len(elements)
settings = ifcopenshell.geom.settings()
failures = []
excludes = () # For the developer to debug with
for i, element in enumerate(elements):
if element.GlobalId in excludes:
continue
print(f'{i}/{total}:', element)
try:
shape = ifcopenshell.geom.create_shape(settings, element)
print("Success", len(shape.geometry.verts), len(shape.geometry.edges), len(shape.geometry.faces))
except:
failures.append(element)
print('***** FAILURE *****')
print('Failures:')
for failure in failures:
print(failure)
return {"FINISHED"}
class CreateShapeFromStepId(bpy.types.Operator):
bl_idname = "bim.create_shape_from_step_id"
bl_label = "Create Shape From STEP ID"
@@ -20,6 +20,9 @@ class BIM_PT_debug(Panel):
row.operator("bim.validate_ifc_file", icon="CHECKMARK", text="")
row.operator("bim.select_ifc_file", icon="FILE_FOLDER", text="")
row = layout.row()
row.operator("bim.create_all_shapes")
row = layout.row()
row.operator("bim.profile_import_ifc")