update ifctester - 2023_07_14

This commit is contained in:
c4rlosdias
2023-07-14 12:04:22 -03:00
parent 654e884e8e
commit 13295d2abf
6 changed files with 94 additions and 10 deletions
+1
View File
@@ -44,3 +44,4 @@ if sys.modules.get("bpy", None):
def unregister():
blenderbim.bim.unregister()
+1 -1
View File
@@ -257,7 +257,7 @@ def viewport_shading_changed_callback(area):
bpy.context.scene.BIMStylesProperties.active_style_type = "External"
if getattr(bpy.types, "SCENE_PT_scene"):
if (bpy.types, "SCENE_PT_scene"):
class Override_SCENE_PT_scene(bpy.types.SCENE_PT_scene):
bl_idname = "SCENE_PT_scene_override"
@@ -23,8 +23,11 @@ classes = (
operator.ExecuteIfcTester,
operator.SelectSpecs,
operator.SelectIfcTesterIfcFile,
operator.SelectSpecification,
prop.Specification,
prop.IfcTesterProperties,
ui.BIM_PT_tester,
ui.BIM_UL_tester
)
@@ -21,6 +21,7 @@ import bpy
import time
import tempfile
import webbrowser
import json
import ifctester
import ifctester.ids
import ifctester.reporter
@@ -53,13 +54,30 @@ class ExecuteIfcTester(bpy.types.Operator):
print("Finished loading:", time.time() - start)
start = time.time()
specs.validate(ifc)
print("Finished validating:", time.time() - start)
start = time.time()
engine = ifctester.reporter.Html(specs)
engine.report()
engine.report()
engine.to_file(output)
webbrowser.open("file://" + output)
report = None
report = ifctester.reporter.Json(specs).report()['specifications']
if report:
props.has_report = True
print(report)
props.specifications.clear()
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'])
return {"FINISHED"}
@@ -95,3 +113,13 @@ class SelectIfcTesterIfcFile(bpy.types.Operator):
def invoke(self, context, event):
context.window_manager.fileselect_add(self)
return {"RUNNING_MODAL"}
class SelectSpecification(bpy.types.Operator):
bl_idname = "bim.select_specification"
bl_label = "Select Specification"
bl_options = {"REGISTER", "UNDO"}
spec: bpy.props.IntProperty()
def execute(self, context):
context.scene.IfcTesterProperties.entities = self.spec
return {"FINISHED"}
@@ -28,13 +28,32 @@ from bpy.props import (
FloatVectorProperty,
CollectionProperty,
)
import bpy.props
def purge():
pass
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 IfcTesterProperties(PropertyGroup):
specs: StringProperty(default="", name="IDS File")
report: StringProperty(default="", name="JSON report")
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")
specifications: CollectionProperty(name="Specifications", type=Specification)
named_specifications: EnumProperty(items=[("11111", "11111", "11")], name="Named Unit Types")
has_report : BoolProperty(default=False, name="")
entities : IntProperty(name="Failed Entities")
@@ -17,7 +17,7 @@
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
import blenderbim.tool as tool
from bpy.types import Panel
from bpy.types import Panel, UIList
class BIM_PT_tester(Panel):
@@ -32,20 +32,53 @@ class BIM_PT_tester(Panel):
def draw(self, context):
self.layout.use_property_split = True
props = context.scene.IfcTesterProperties
self.props = context.scene.IfcTesterProperties
if tool.Ifc.get():
row = self.layout.row()
row.prop(props, "should_load_from_memory")
row.prop(self.props, "should_load_from_memory")
if not tool.Ifc.get() or not props.should_load_from_memory:
if not tool.Ifc.get() or not self.props.should_load_from_memory:
row = self.layout.row(align=True)
row.prop(props, "ifc_file")
row.prop(self.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.prop(self.props, "specs")
row.operator("bim.select_specs", icon="FILE_FOLDER", text="")
row = self.layout.row()
row.operator("bim.execute_ifc_tester")
result = row.operator("bim.execute_ifc_tester")
if self.props.has_report:
self.layout.template_list(
"BIM_UL_tester",
"",
self.props,
"specifications",
self.props,
"active_specification_index",
)
self.draw_editable_ui(context)
def draw_editable_ui(self, context):
props = context.scene.IfcTesterProperties
row = self.layout.row()
row.label(text="Failed entities: " + str(props.entities))
class BIM_UL_tester(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
props = context.scene.IfcTesterProperties
if item:
icon = "MOD_MESHDEFORM"
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