mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
add button
This commit is contained in:
@@ -25,6 +25,7 @@ classes = (
|
|||||||
operator.StopIfcTesterWebapp,
|
operator.StopIfcTesterWebapp,
|
||||||
operator.OpenIfcTesterWebapp,
|
operator.OpenIfcTesterWebapp,
|
||||||
operator.SelectRequirement,
|
operator.SelectRequirement,
|
||||||
|
operator.ColorSpecefication,
|
||||||
operator.SelectFailedEntities,
|
operator.SelectFailedEntities,
|
||||||
operator.ExportBcf,
|
operator.ExportBcf,
|
||||||
prop.FailedEntities,
|
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.")
|
self.report({"INFO"}, f"{len(failed_ids)} failed entities found, {len(context.selected_objects)} selected.")
|
||||||
return {"FINISHED"}
|
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):
|
class ExportBcf(bpy.types.Operator, ExportHelper):
|
||||||
bl_idname = "bim.export_bcf"
|
bl_idname = "bim.export_bcf"
|
||||||
|
|||||||
@@ -112,6 +112,9 @@ class BIM_PT_tester(Panel):
|
|||||||
)
|
)
|
||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.label(text=f"Requirements ({n_requirements}):")
|
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()
|
box = self.layout.box()
|
||||||
for i, requirement in enumerate(specification["requirements"]):
|
for i, requirement in enumerate(specification["requirements"]):
|
||||||
row = box.row(align=True)
|
row = box.row(align=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user