From d30286225c1cf70562848ae0a9803529a047e995 Mon Sep 17 00:00:00 2001 From: Petru Conduraru Date: Thu, 9 Jul 2026 13:43:43 +0300 Subject: [PATCH] Bonsai: deterministic annotation order in generated drawing SVGs (#6608) generate_annotation built the annotation list from a set union and sorted it by ZIndex and TEXT-ness only. Annotations that tied on that key kept set iteration order, which follows entity hash (step id plus the process memory address), so the order of tied annotations (for example a label and its background fill) shuffled between Blender restarts and flipped their draw order. Add the stable IFC step id as a final tiebreaker so the order is total and session independent. Behavior preserving, no z-layer semantics changed. Co-Authored-By: Claude Opus 4.8 --- src/bonsai/bonsai/bim/module/drawing/operator.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bonsai/bonsai/bim/module/drawing/operator.py b/src/bonsai/bonsai/bim/module/drawing/operator.py index 7c53067a00..6846b1b91c 100644 --- a/src/bonsai/bonsai/bim/module/drawing/operator.py +++ b/src/bonsai/bonsai/bim/module/drawing/operator.py @@ -1706,6 +1706,12 @@ class CreateDrawing(bpy.types.Operator): key=lambda a: ( tool.Drawing.get_annotation_z_index(a), 1 if ifcopenshell.util.element.get_predefined_type(a) == "TEXT" else 0, + # Deterministic tiebreaker so equal-priority annotations keep a + # stable order across sessions. Without it the order comes from + # the set union above, which depends on entity hashes (and thus + # the file pointer), shuffling annotations between Blender + # restarts. See #6608. + a.id(), ), )