mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
@@ -29,41 +29,37 @@ from bpy.props import (
|
||||
CollectionProperty,
|
||||
)
|
||||
|
||||
|
||||
def purge():
|
||||
pass
|
||||
|
||||
|
||||
def get_failure_entities():
|
||||
return
|
||||
|
||||
|
||||
|
||||
class Specification(PropertyGroup):
|
||||
name: StringProperty(name="Name")
|
||||
status : BoolProperty(default=False, name="Status")
|
||||
status: BoolProperty(default=False, name="Status")
|
||||
|
||||
|
||||
class FailedEntities(PropertyGroup):
|
||||
reason: StringProperty(name="Reason")
|
||||
element: StringProperty(name="Element")
|
||||
|
||||
|
||||
|
||||
class IfcTesterProperties(PropertyGroup):
|
||||
specs: StringProperty(default="", name="IDS File")
|
||||
specs: StringProperty(default="", name="IDS File")
|
||||
ifc_file: StringProperty(default="", name="IFC File")
|
||||
|
||||
should_load_from_memory: BoolProperty(default=False, name="Load from Memory",
|
||||
description="Use the currently opened IFC project. Required for the detailed Tester UI")
|
||||
should_load_from_memory: BoolProperty(default=False, name="Load from Memory")
|
||||
generate_html_report: BoolProperty(default=False, name="Generate HTML report")
|
||||
|
||||
active_specification_index: IntProperty(name="Active Specification Index")
|
||||
active_specification_index: IntProperty(name="Active Specification Index")
|
||||
active_requirement_index: IntProperty(name="Active Requirement Index")
|
||||
old_index: IntProperty(name="", default=0)
|
||||
active_failed_entity_index: IntProperty(name="Active Failed Entity Index")
|
||||
active_failed_entity_index: IntProperty(name="Active Failed Entity Index")
|
||||
report: StringProperty(default="", name="JSON report")
|
||||
specifications: CollectionProperty(name="Specifications", type=Specification)
|
||||
failed_entities: CollectionProperty(name="FailedEntities", type=FailedEntities)
|
||||
has_report : BoolProperty(default=False, name="")
|
||||
has_entities : BoolProperty(default=False, name="")
|
||||
n_entities : IntProperty(name="", default=0)
|
||||
|
||||
|
||||
|
||||
has_report: BoolProperty(default=False, name="")
|
||||
has_entities: BoolProperty(default=False, name="")
|
||||
n_entities: IntProperty(name="", default=0)
|
||||
|
||||
@@ -34,19 +34,18 @@ class BIM_PT_tester(Panel):
|
||||
self.layout.use_property_split = True
|
||||
props = context.scene.IfcTesterProperties
|
||||
|
||||
row = self.layout.row()
|
||||
row.prop(self.props, "should_load_from_memory")
|
||||
row.enabled = bool(tool.Ifc.get())
|
||||
|
||||
if tool.Ifc.get():
|
||||
row = self.layout.row()
|
||||
row.prop(self.props, "should_load_from_memory")
|
||||
|
||||
row = self.layout.row()
|
||||
row.prop(props, "generate_html_report")
|
||||
|
||||
|
||||
if not tool.Ifc.get() or not props.should_load_from_memory:
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(props, "ifc_file")
|
||||
row.operator("bim.select_ifctester_ifc_file", icon="FILE_FOLDER", text="")
|
||||
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.prop(props, "specs")
|
||||
row.operator("bim.select_specs", icon="FILE_FOLDER", text="")
|
||||
@@ -69,25 +68,25 @@ class BIM_PT_tester(Panel):
|
||||
row.operator("bim.export_bcf", text="Export BCF", icon="EXPORT")
|
||||
|
||||
def draw_editable_ui(self, context):
|
||||
props = context.scene.IfcTesterProperties
|
||||
props = context.scene.IfcTesterProperties
|
||||
i = props.active_specification_index
|
||||
dic_report = json.loads(props.report)
|
||||
|
||||
total_successes = dic_report[i]['total_successes']
|
||||
total = dic_report[i]['total']
|
||||
percentage = dic_report[i]['percentage']
|
||||
n_requirements = len(dic_report[i]['requirements'])
|
||||
|
||||
total_successes = dic_report[i]["total_successes"]
|
||||
total = dic_report[i]["total"]
|
||||
percentage = dic_report[i]["percentage"]
|
||||
n_requirements = len(dic_report[i]["requirements"])
|
||||
|
||||
row = self.layout.row()
|
||||
row.label(text = f"Passed: {total_successes}/{total} ({percentage}%)")
|
||||
row.label(text=f"Passed: {total_successes}/{total} ({percentage}%)")
|
||||
row = self.layout.row()
|
||||
row.label(text = f"Requirements ({n_requirements}):")
|
||||
c=0
|
||||
box = self.layout.box()
|
||||
for req in dic_report[i]['requirements']:
|
||||
row.label(text=f"Requirements ({n_requirements}):")
|
||||
c = 0
|
||||
box = self.layout.box()
|
||||
for req in dic_report[i]["requirements"]:
|
||||
row = box.row(align=True)
|
||||
row.label(text=f" {c+1}. {req['description']}")
|
||||
if req['status']:
|
||||
if req["status"]:
|
||||
row.label(text="PASS", icon="CHECKMARK")
|
||||
else:
|
||||
row.label(text="FAIL", icon="CANCEL")
|
||||
@@ -95,10 +94,10 @@ class BIM_PT_tester(Panel):
|
||||
op.spec_index = i
|
||||
op.req_index = c
|
||||
c += 1
|
||||
|
||||
if props.old_index == i and props.n_entities > 0:
|
||||
|
||||
if props.old_index == i and props.n_entities > 0:
|
||||
row = self.layout.row()
|
||||
row.label(text = f"Failed entities [{props.n_entities}]:")
|
||||
row.label(text=f"Failed entities [{props.n_entities}]:")
|
||||
self.layout.template_list(
|
||||
"BIM_UL_tester_failed_entities",
|
||||
"",
|
||||
@@ -107,9 +106,8 @@ class BIM_PT_tester(Panel):
|
||||
props,
|
||||
"active_failed_entity_index",
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
class BIM_UL_tester_specifications(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
if item:
|
||||
@@ -120,23 +118,22 @@ class BIM_UL_tester_specifications(UIList):
|
||||
else:
|
||||
row.label(text="FAIL")
|
||||
|
||||
|
||||
class BIM_UL_tester_failed_entities(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
props = context.scene.IfcTesterProperties
|
||||
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('=')])
|
||||
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}'
|
||||
report_entity = f"[#{ifc_id}][{entity.is_a()}] {entity.Name}"
|
||||
else:
|
||||
report_entity = item.element
|
||||
|
||||
row = layout.row(align=True)
|
||||
row = layout.row(align=True)
|
||||
row.label(text=report_entity)
|
||||
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()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user