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.ExecuteIfcTester,
operator.SelectSpecs, operator.SelectSpecs,
operator.SelectIfcTesterIfcFile, operator.SelectIfcTesterIfcFile,
operator.SelectSpecification, operator.SelectRequirement,
prop.FailedEntities,
prop.Specification, prop.Specification,
prop.IfcTesterProperties, prop.IfcTesterProperties,
ui.BIM_PT_tester, 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(): def unregister():
del bpy.types.Scene.IfcTesterProperties del bpy.types.Scene.IfcTesterProperties
@@ -67,16 +67,13 @@ class ExecuteIfcTester(bpy.types.Operator):
report = ifctester.reporter.Json(specs).report()['specifications'] report = ifctester.reporter.Json(specs).report()['specifications']
if report: if report:
props.has_report = True props.has_report = True
print(report) props.report = json.dumps(report)
props.specifications.clear() props.specifications.clear()
c=0
for spec in report: for spec in report:
new = props.specifications.add() new_spec = props.specifications.add()
new.name = spec['name'] new_spec.name = spec['name']
new.status = spec['status'] new_spec.status = spec['status']
new.sucess = spec['total_sucess']
new.description = spec['requirements'][0]['description']
new.failed_entities = len(spec['requirements'][0]['failed_entities'])
return {"FINISHED"} return {"FINISHED"}
@@ -114,12 +111,25 @@ class SelectIfcTesterIfcFile(bpy.types.Operator):
context.window_manager.fileselect_add(self) context.window_manager.fileselect_add(self)
return {"RUNNING_MODAL"} 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_label = "Select Specification"
bl_options = {"REGISTER", "UNDO"} bl_options = {"REGISTER", "UNDO"}
spec: bpy.props.IntProperty() spec_index: bpy.props.IntProperty()
req_index: bpy.props.IntProperty()
def execute(self, context): 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"} return {"FINISHED"}
@@ -28,7 +28,6 @@ from bpy.props import (
FloatVectorProperty, FloatVectorProperty,
CollectionProperty, CollectionProperty,
) )
import bpy.props
def purge(): def purge():
pass pass
@@ -37,23 +36,29 @@ def get_failure_entities():
return return
class Specification(PropertyGroup): class Specification(PropertyGroup):
name: StringProperty(name="Name") name: StringProperty(name="Name")
failed_entities: IntProperty(name="Failed Entities")
description : StringProperty(name="Description")
status : BoolProperty(default=False, name="Status") 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): class IfcTesterProperties(PropertyGroup):
specs: StringProperty(default="", name="IDS File") specs: StringProperty(default="", name="IDS File")
report: StringProperty(default="", name="JSON report")
ifc_file: StringProperty(default="", name="IFC File") ifc_file: StringProperty(default="", name="IFC File")
should_load_from_memory: BoolProperty(default=False, name="Load from Memory") 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) 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="") 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 import blenderbim.tool as tool
from bpy.types import Panel, UIList from bpy.types import Panel, UIList
import json
class BIM_PT_tester(Panel): class BIM_PT_tester(Panel):
@@ -52,7 +53,7 @@ class BIM_PT_tester(Panel):
if self.props.has_report: if self.props.has_report:
self.layout.template_list( self.layout.template_list(
"BIM_UL_tester", "BIM_UL_tester_specifications",
"", "",
self.props, self.props,
"specifications", "specifications",
@@ -64,21 +65,60 @@ class BIM_PT_tester(Panel):
def draw_editable_ui(self, context): def draw_editable_ui(self, context):
props = context.scene.IfcTesterProperties props = context.scene.IfcTesterProperties
row = self.layout.row() i = props.active_specification_index
row.label(text="Failed entities: " + str(props.entities)) 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): def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
props = context.scene.IfcTesterProperties props = context.scene.IfcTesterProperties
if item: if item:
icon = "MOD_MESHDEFORM" icon = "WORDWRAP_ON"
row = layout.row(align=True) row = layout.row(align=True)
row.label(text=item.name or "Unnamed", icon=icon) row.label(text=item.name or "Unnamed", icon=icon)
if item.status: if item.status:
row.label(text="PASS") row.label(text="PASS")
else: else:
row.label(text="FAIL") 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)