Add "hide empty Specifications" to Bonsai IFCTester (#7190)

* add filter

* apply filter property

* allow name filter

* black .

* add hide-skipped to html

* rename prop

* only hide optional specifications
This commit is contained in:
Christoph Mellüh
2025-10-06 06:49:35 +02:00
committed by GitHub
parent 16fd614886
commit 8e045d772c
5 changed files with 46 additions and 7 deletions
@@ -135,6 +135,7 @@ class IfcTesterNamespace(socketio.AsyncNamespace):
try:
request_id = data.get("id")
ids_string = data.get("ids")
props = tool.Tester.get_tester_props()
if not request_id:
await self.emit("error", {"error": "No request ID provided"}, room=sid)
@@ -176,7 +177,7 @@ class IfcTesterNamespace(socketio.AsyncNamespace):
json_report = json_reporter.to_string()
# HTML report
html_reporter = ifctester.reporter.Html(ids)
html_reporter = ifctester.reporter.Html(ids, hide_skipped=props.hide_skipped_specs)
html_reporter.report()
html_report = html_reporter.to_string()
@@ -267,7 +268,7 @@ class ExecuteIfcTester(bpy.types.Operator):
start = time.time()
if props.generate_html_report:
engine = ifctester.reporter.Html(specs)
engine = ifctester.reporter.Html(specs, props.hide_skipped_specs)
engine.report()
output_path = output.as_posix()
engine.to_file(output_path)
@@ -82,6 +82,7 @@ class IfcTesterProperties(PropertyGroup):
webapp_server_port: IntProperty(name="Webapp Server Port", default=0)
webapp_is_running: BoolProperty(default=False, name="Webapp Is Running", options=set())
websocket_server_port: IntProperty(name="WebSocket Server Port", default=0)
hide_skipped_specs: BoolProperty(default=False, name="Hide skipped Specifications", options=set())
if TYPE_CHECKING:
specs: MultipleFileSelect
+33 -1
View File
@@ -62,7 +62,8 @@ class BIM_PT_tester(Panel):
row.prop(props, "generate_ods_report")
row = self.layout.row()
row.prop(props, "flag")
row = self.layout.row()
row.prop(props, "hide_skipped_specs")
if not tool.Ifc.get() or not props.should_load_from_memory:
row = self.layout.row(align=True)
props.ifc_files.layout_file_select(row, "*.ifc;*.ifczip;*.ifcxml", "IFC File(s)")
@@ -104,6 +105,9 @@ class BIM_PT_tester(Panel):
def draw_editable_ui(self, context: bpy.types.Context) -> None:
props = tool.Tester.get_tester_props()
specification = TesterData.data["specification"]
is_skipped = specification["total_checks"] == 0 and specification["cardinality"] == "optional"
if props.hide_skipped_specs and is_skipped:
return
n_requirements = len(specification["requirements"])
@@ -179,6 +183,34 @@ class BIM_UL_tester_specifications(UIList):
row.label(text=item.name, icon="CHECKMARK" if item.status else "CANCEL")
row.label(text=item.description)
def filter_items(self, context: bpy.types.Context, data: IfcTesterProperties, propname: str):
items = getattr(data, propname)
filter_flags = [self.bitflag_filter_item] * len(items)
props = tool.Tester.get_tester_props()
if props.hide_skipped_specs:
for idx, item in enumerate(items):
report = tool.Tester.report[idx]
if report["total_checks"] != 0:
filter_flags[idx] |= self.bitflag_filter_item
else:
filter_flags[idx] &= ~self.bitflag_filter_item
filter_name = self.filter_name
if filter_name:
name_filtered = bpy.types.UI_UL_list.filter_items_by_name(
filter_name,
self.bitflag_filter_item,
items,
"name",
)
if len(name_filtered) == len(filter_flags):
for idx, flag in enumerate(name_filtered):
if flag == 0:
filter_flags[idx] &= ~self.bitflag_filter_item
return filter_flags, []
class BIM_UL_tester_failed_entities(UIList):
def draw_item(