mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
add button
This commit is contained in:
@@ -25,6 +25,7 @@ classes = (
|
||||
operator.StopIfcTesterWebapp,
|
||||
operator.OpenIfcTesterWebapp,
|
||||
operator.SelectRequirement,
|
||||
operator.ColorSpecefication,
|
||||
operator.SelectFailedEntities,
|
||||
operator.ExportBcf,
|
||||
prop.FailedEntities,
|
||||
|
||||
@@ -520,6 +520,35 @@ class SelectFailedEntities(bpy.types.Operator):
|
||||
self.report({"INFO"}, f"{len(failed_ids)} failed entities found, {len(context.selected_objects)} selected.")
|
||||
return {"FINISHED"}
|
||||
|
||||
class ColorSpecefication(bpy.types.Operator):
|
||||
"""Colors all entities red that failed each test and color all entities yellow that failed some tests"""
|
||||
bl_idname = "bim.color_specification"
|
||||
bl_label = "Color Failed Entities"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
spec_index: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
props = context.scene.IfcTesterProperties
|
||||
report = tool.Tester.report
|
||||
|
||||
failures = [{e["id"] for e in requirement["failed_entities"]} for requirement in report[self.spec_index]["requirements"]]
|
||||
failed_all_ids = set.intersection(*failures)
|
||||
failed_some_ids = set.union(*failures)-failed_all_ids
|
||||
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
|
||||
for obj in context.scene.objects:
|
||||
ifc_id = tool.Blender.get_ifc_definition_id(obj)
|
||||
if ifc_id in failed_all_ids:
|
||||
obj.color = (1, 0, 0, 1)
|
||||
elif ifc_id in failed_some_ids:
|
||||
obj.color = (1, 1, 0, 1)
|
||||
else:
|
||||
obj.color = (1, 1, 1, 1)
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class ExportBcf(bpy.types.Operator, ExportHelper):
|
||||
bl_idname = "bim.export_bcf"
|
||||
|
||||
@@ -112,6 +112,9 @@ class BIM_PT_tester(Panel):
|
||||
)
|
||||
row = self.layout.row()
|
||||
row.label(text=f"Requirements ({n_requirements}):")
|
||||
if props.flag:
|
||||
op = row.operator("bim.color_specification", text="", icon="COLOR")
|
||||
op.spec_index = props.active_specification_index
|
||||
box = self.layout.box()
|
||||
for i, requirement in enumerate(specification["requirements"]):
|
||||
row = box.row(align=True)
|
||||
|
||||
Reference in New Issue
Block a user