Fix crash where IFCTester read directly from IFC in the UI

This commit is contained in:
Dion Moult
2023-09-19 18:15:56 +10:00
parent a7f33d8172
commit af9ce9d8fd
5 changed files with 15 additions and 17 deletions
@@ -131,7 +131,8 @@ class SelectRequirement(bpy.types.Operator):
props.failed_entities.clear()
for e in failed_entities:
new_entity = props.failed_entities.add()
new_entity.element = e["element"]
new_entity.ifc_id = e["id"]
new_entity.element = f'{e["class"]}/{e["name"]}'
new_entity.reason = e["reason"]
return {"FINISHED"}
@@ -41,8 +41,9 @@ class Specification(PropertyGroup):
class FailedEntities(PropertyGroup):
reason: StringProperty(name="Reason")
ifc_id: IntProperty(name="IFC ID")
element: StringProperty(name="Element")
reason: StringProperty(name="Reason")
class IfcTesterProperties(PropertyGroup):
@@ -115,17 +115,9 @@ class BIM_UL_tester_failed_entities(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
props = context.scene.IfcTesterProperties
if item:
if props.should_load_from_memory:
ifc_file = tool.Ifc.get()
ifc_id = int(item.element[1 : item.element.find("=")])
entity = ifc_file.by_id(ifc_id)
report_entity = f"[#{ifc_id}][{entity.is_a()}] {entity.Name}"
else:
report_entity = item.element
row = layout.row(align=True)
row.label(text=report_entity)
row.label(text=item.element)
row.label(text=item.reason)
if props.should_load_from_memory:
op = row.operator("bim.select_entity", text="", icon="RESTRICT_SELECT_OFF")
op.ifc_id = entity.id()
op.ifc_id = item.ifc_id