Update 2023_07_16

This commit is contained in:
c4rlosdias
2023-07-16 20:46:26 -03:00
parent 772414451e
commit 31bb220d38
4 changed files with 89 additions and 31 deletions
@@ -23,11 +23,13 @@ classes = (
operator.ExecuteIfcTester,
operator.SelectSpecs,
operator.SelectIfcTesterIfcFile,
operator.SelectSpecification,
operator.SelectRequirement,
prop.FailedEntities,
prop.Specification,
prop.IfcTesterProperties,
ui.BIM_PT_tester,
ui.BIM_UL_tester
ui.BIM_UL_tester_specifications,
ui.BIM_UL_tester_failed_entities
)
@@ -37,3 +39,4 @@ def register():
def unregister():
del bpy.types.Scene.IfcTesterProperties
@@ -67,16 +67,13 @@ class ExecuteIfcTester(bpy.types.Operator):
report = ifctester.reporter.Json(specs).report()['specifications']
if report:
props.has_report = True
print(report)
props.report = json.dumps(report)
props.specifications.clear()
c=0
for spec in report:
new = props.specifications.add()
new.name = spec['name']
new.status = spec['status']
new.sucess = spec['total_sucess']
new.description = spec['requirements'][0]['description']
new.failed_entities = len(spec['requirements'][0]['failed_entities'])
new_spec = props.specifications.add()
new_spec.name = spec['name']
new_spec.status = spec['status']
return {"FINISHED"}
@@ -114,12 +111,25 @@ class SelectIfcTesterIfcFile(bpy.types.Operator):
context.window_manager.fileselect_add(self)
return {"RUNNING_MODAL"}
class SelectSpecification(bpy.types.Operator):
bl_idname = "bim.select_specification"
class SelectRequirement(bpy.types.Operator):
bl_idname = "bim.select_requirement"
bl_label = "Select Specification"
bl_options = {"REGISTER", "UNDO"}
spec: bpy.props.IntProperty()
spec_index: bpy.props.IntProperty()
req_index: bpy.props.IntProperty()
def execute(self, context):
context.scene.IfcTesterProperties.entities = self.spec
props = context.scene.IfcTesterProperties
props.has_entities = True
report = json.loads(props.report)
props.failed_entities.clear()
failed_entities = report[self.spec_index]['requirements'] [self.req_index]['failed_entities']
print(failed_entities)
for e in failed_entities:
new_entity = props.failed_entities.add()
new_entity.reason = e['reason']
new_entity.element = e['element']
return {"FINISHED"}
@@ -28,7 +28,6 @@ from bpy.props import (
FloatVectorProperty,
CollectionProperty,
)
import bpy.props
def purge():
pass
@@ -37,23 +36,29 @@ def get_failure_entities():
return
class Specification(PropertyGroup):
name: StringProperty(name="Name")
failed_entities: IntProperty(name="Failed Entities")
description : StringProperty(name="Description")
status : BoolProperty(default=False, name="Status")
sucess : IntProperty(name="Total sucess")
ifc_definition_id: IntProperty(name="IFC Definition ID")
class FailedEntities(PropertyGroup):
reason: StringProperty(name="Reason")
element: StringProperty(name="Element")
class IfcTesterProperties(PropertyGroup):
specs: StringProperty(default="", name="IDS File")
report: StringProperty(default="", name="JSON report")
specs: StringProperty(default="", name="IDS File")
ifc_file: StringProperty(default="", name="IFC File")
should_load_from_memory: BoolProperty(default=False, name="Load from Memory")
active_specification_index: IntProperty(name="Active Specification Index")
active_specification_index: IntProperty(name="Active Specification Index")
active_requirement_index: IntProperty(name="Active Requirement Index")
active_failed_entity_index: IntProperty(name="Active Failed Entity Index")
report: StringProperty(default="", name="JSON report")
specifications: CollectionProperty(name="Specifications", type=Specification)
named_specifications: EnumProperty(items=[("11111", "11111", "11")], name="Named Unit Types")
failed_entities: CollectionProperty(name="FailedEntities", type=FailedEntities)
has_report : BoolProperty(default=False, name="")
entities : IntProperty(name="Failed Entities")
has_entities : BoolProperty(default=False, name="")
@@ -18,6 +18,7 @@
import blenderbim.tool as tool
from bpy.types import Panel, UIList
import json
class BIM_PT_tester(Panel):
@@ -52,7 +53,7 @@ class BIM_PT_tester(Panel):
if self.props.has_report:
self.layout.template_list(
"BIM_UL_tester",
"BIM_UL_tester_specifications",
"",
self.props,
"specifications",
@@ -64,21 +65,60 @@ class BIM_PT_tester(Panel):
def draw_editable_ui(self, context):
props = context.scene.IfcTesterProperties
row = self.layout.row()
row.label(text="Failed entities: " + str(props.entities))
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'])
row = self.layout.row()
row.label(text = f"Passed: {total_successes}/{total} ({percentage}%)")
row = self.layout.row()
row.label(text = f"Requirements ({n_requirements}):")
c=1
box = self.layout.box()
for req in dic_report[i]['requirements']:
row = box.row(align=True)
row.label(text=f" {c}. {req['description']}")
if req['status']:
row.label(text="PASS")
else:
row.label(text="FAIL")
op = row.operator("bim.select_requirement", text="", icon="RESTRICT_SELECT_OFF")
op.spec_index = i
op.req_index = c - 1
c += 1
if props.has_entities:
self.layout.template_list(
"BIM_UL_tester_failed_entities",
"",
self.props,
"failed_entities",
self.props,
"active_failed_entity_index",
)
class BIM_UL_tester(UIList):
class BIM_UL_tester_specifications(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
props = context.scene.IfcTesterProperties
if item:
icon = "MOD_MESHDEFORM"
icon = "WORDWRAP_ON"
row = layout.row(align=True)
row.label(text=item.name or "Unnamed", icon=icon)
if item.status:
row.label(text="PASS")
else:
row.label(text="FAIL")
op = row.operator("bim.select_specification", text="", icon="VIEWZOOM")
op.spec = item.failed_entities
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:
icon = "WORDWRAP_ON"
row = layout.row(align=True)
row.label(text=item.reason)
row.label(text=eval(item.element).Name)