From 0df7117d3714f781c86ba246236d981ef84e34f6 Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Tue, 11 Nov 2025 14:26:55 -0600 Subject: [PATCH] Sort annotations to ensure FILLAREA types are drawn first (at the bottom) --- src/bonsai/bonsai/bim/module/drawing/svgwriter.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bonsai/bonsai/bim/module/drawing/svgwriter.py b/src/bonsai/bonsai/bim/module/drawing/svgwriter.py index 18900be5e5..96fe593a99 100644 --- a/src/bonsai/bonsai/bim/module/drawing/svgwriter.py +++ b/src/bonsai/bonsai/bim/module/drawing/svgwriter.py @@ -202,6 +202,15 @@ class SvgWriter: ) -> Self: self.precision = precision self.decimal_places = decimal_places + + # Sort annotations to ensure FILLAREA types are drawn first (at the bottom) + def sort_key(element): + predefined_type = ifcopenshell.util.element.get_predefined_type(element) + # Return 0 for FILLAREA to draw them first, 1 for everything else + return 0 if predefined_type == "FILL_AREA" else 1 + + annotations = sorted(annotations, key=sort_key) + for element in annotations: obj = tool.Ifc.get_object(element) if (