mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Update IfcTester and Tester module of Blenderbim
This commit is contained in:
@@ -131,11 +131,48 @@ class SelectRequirement(bpy.types.Operator):
|
||||
props.n_entities = len(failed_entities)
|
||||
props.has_entities = True if props.n_entities > 0 else False
|
||||
props.failed_entities.clear()
|
||||
|
||||
for e in failed_entities:
|
||||
new_entity = props.failed_entities.add()
|
||||
new_entity.ifc_id = e["id"]
|
||||
new_entity.element = f'{e["class"]}/{e["name"]}'
|
||||
new_entity.element = f'{e["class"]} | {e["name"]}'
|
||||
new_entity.reason = e["reason"]
|
||||
|
||||
if props.flag:
|
||||
area = next(area for area in context.screen.areas if area.type == "VIEW_3D")
|
||||
area.spaces[0].shading.color_type = "OBJECT"
|
||||
area.spaces[0].shading.show_xray = True
|
||||
failed_ids = [ e["id"] for e in failed_entities ]
|
||||
for obj in context.scene.objects:
|
||||
if obj.BIMObjectProperties.ifc_definition_id in failed_ids:
|
||||
obj.color = (1,0,0,1)
|
||||
else:
|
||||
obj.color = (1,1,1,1)
|
||||
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
class SelectFailedEntities(bpy.types.Operator):
|
||||
bl_idname = "bim.select_failed_entities"
|
||||
bl_label = "Select Failed Entities"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
spec_index: bpy.props.IntProperty()
|
||||
req_index: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
props = context.scene.IfcTesterProperties
|
||||
report = tool.Tester.report
|
||||
props.old_index = self.spec_index
|
||||
failed_entities = report[self.spec_index]["requirements"][self.req_index]["failed_entities"]
|
||||
props.n_entities = len(failed_entities)
|
||||
props.has_entities = True if props.n_entities > 0 else False
|
||||
|
||||
failed_ids = [ e["id"] for e in failed_entities ]
|
||||
for obj in context.scene.objects:
|
||||
if obj.BIMObjectProperties.ifc_definition_id in failed_ids:
|
||||
obj.select_set(True)
|
||||
else:
|
||||
obj.select_set(False)
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ class IfcTesterProperties(PropertyGroup):
|
||||
ifc_file: StringProperty(default="", name="IFC File")
|
||||
should_load_from_memory: BoolProperty(default=False, name="Load from Memory")
|
||||
generate_html_report: BoolProperty(default=False, name="Generate HTML report")
|
||||
flag : BoolProperty(default=False, name="Flag failed entities")
|
||||
active_specification_index: IntProperty(name="Active Specification Index", update=update_active_specification_index)
|
||||
old_index: IntProperty(name="", default=0)
|
||||
active_failed_entity_index: IntProperty(name="Active Failed Entity Index")
|
||||
|
||||
@@ -43,6 +43,8 @@ class BIM_PT_tester(Panel):
|
||||
|
||||
row = self.layout.row()
|
||||
row.prop(props, "generate_html_report")
|
||||
row = self.layout.row()
|
||||
row.prop(props, "flag")
|
||||
|
||||
if not tool.Ifc.get() or not props.should_load_from_memory:
|
||||
row = self.layout.row(align=True)
|
||||
@@ -87,9 +89,12 @@ class BIM_PT_tester(Panel):
|
||||
row = box.row(align=True)
|
||||
row.label(text=requirement["description"], icon="CHECKMARK" if requirement["status"] else "CANCEL")
|
||||
if not requirement["status"]:
|
||||
op = row.operator("bim.select_requirement", text="", icon="LONGDISPLAY")
|
||||
op = row.operator("bim.select_requirement", text="", icon="LONGDISPLAY")
|
||||
op2 = row.operator("bim.select_failed_entities", text="", icon="RESTRICT_SELECT_OFF")
|
||||
op.spec_index = props.active_specification_index
|
||||
op.req_index = i
|
||||
op2.spec_index = props.active_specification_index
|
||||
op2.req_index = i
|
||||
|
||||
if props.old_index == props.active_specification_index and props.n_entities > 0:
|
||||
row = self.layout.row()
|
||||
|
||||
@@ -224,7 +224,11 @@ class Specification:
|
||||
self.applicable_entities.append(element)
|
||||
for facet in self.requirements:
|
||||
result = facet(element)
|
||||
if not bool(result):
|
||||
if self.maxOccurs == 0:
|
||||
prohibited = bool(result)
|
||||
else:
|
||||
prohibited = not bool(result)
|
||||
if prohibited:
|
||||
self.failed_entities.add(element)
|
||||
facet.failed_entities.append(element)
|
||||
facet.failed_reasons.append(str(result))
|
||||
|
||||
@@ -217,7 +217,7 @@ class Json(Reporter):
|
||||
total_checks_pass += total_pass
|
||||
requirements.append(
|
||||
{
|
||||
"description": requirement.to_string("requirement"),
|
||||
"description": requirement.to_string("requirement") if specification.maxOccurs != 0 else requirement.to_string("requirement").replace('shall', 'shall not'),
|
||||
"status": requirement.status,
|
||||
"failed_entities": self.report_failed_entities(requirement),
|
||||
"total_applicable": total_applicable,
|
||||
|
||||
Reference in New Issue
Block a user