From 151aa2c45ab981660a109ed053b37fef1dff19f1 Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Mon, 24 Aug 2026 22:02:22 -0500 Subject: [PATCH] Bonsai: sort drawing scale dropdown by scale ratio (#9357) The imperial list ran the architectural scales from 1'=1'-0" down to 1/128"=1'-0", then restarted at 1"=10' for the engineering scales. Merge both groups into a single sequence ordered by ratio, largest scale first. The metric list was already ordered by ratio and is unchanged. Also fix the enum cache invalidation, which compared the cached list's length against hardcoded 13/31 while the imperial list has 32 entries, so switching a scene from imperial back to metric kept showing imperial scales. Track the unit system the cache was built for instead. Co-authored-by: Claude Opus 5 --- src/bonsai/bonsai/bim/module/drawing/prop.py | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/drawing/prop.py b/src/bonsai/bonsai/bim/module/drawing/prop.py index bc10632a19..c80f6e897a 100644 --- a/src/bonsai/bonsai/bim/module/drawing/prop.py +++ b/src/bonsai/bonsai/bim/module/drawing/prop.py @@ -50,11 +50,13 @@ from bonsai.bim.module.drawing.data import refresh as refresh_drawing_data from bonsai.bim.prop import Attribute, BIMFilterGroup diagram_scales_enum = [] +diagram_scales_enum_system = None def purge(): - global diagram_scales_enum + global diagram_scales_enum, diagram_scales_enum_system diagram_scales_enum = [] + diagram_scales_enum_system = None def update_target_view_doc(self: "DocProperties", context: bpy.types.Context) -> None: @@ -123,14 +125,12 @@ def update_is_nts(self: "BIMCameraProperties", context: bpy.types.Context) -> No def get_diagram_scales(self: "BIMCameraProperties", context: bpy.types.Context) -> list[tuple[str, str, str]]: - global diagram_scales_enum + global diagram_scales_enum, diagram_scales_enum_system assert context.scene - if ( - len(diagram_scales_enum) < 1 - or (context.scene.unit_settings.system == "IMPERIAL" and len(diagram_scales_enum) == 13) - or (context.scene.unit_settings.system == "METRIC" and len(diagram_scales_enum) == 31) - ): - if context.scene.unit_settings.system == "IMPERIAL": + system = context.scene.unit_settings.system + if len(diagram_scales_enum) < 1 or diagram_scales_enum_system != system: + diagram_scales_enum_system = system + if system == "IMPERIAL": diagram_scales_enum = [ ("CUSTOM", "Custom", ""), ("1'=1'-0\"|1/1", "1'=1'-0\"", ""), @@ -144,21 +144,21 @@ def get_diagram_scales(self: "BIMCameraProperties", context: bpy.types.Context) ('1/4"=1\'-0"|1/48', '1/4"=1\'-0"', ""), ('3/16"=1\'-0"|1/64', '3/16"=1\'-0"', ""), ('1/8"=1\'-0"|1/96', '1/8"=1\'-0"', ""), + ("1\"=10'|1/120", "1\"=10'", ""), ('3/32"=1\'-0"|1/128', '3/32"=1\'-0"', ""), ('1/16"=1\'-0"|1/192', '1/16"=1\'-0"', ""), - ('1/32"=1\'-0"|1/384', '1/32"=1\'-0"', ""), - ('1/64"=1\'-0"|1/768', '1/64"=1\'-0"', ""), - ('1/128"=1\'-0"|1/1536', '1/128"=1\'-0"', ""), - ("1\"=10'|1/120", "1\"=10'", ""), ("1\"=20'|1/240", "1\"=20'", ""), ("1\"=30'|1/360", "1\"=30'", ""), + ('1/32"=1\'-0"|1/384', '1/32"=1\'-0"', ""), ("1\"=40'|1/480", "1\"=40'", ""), ("1\"=50'|1/600", "1\"=50'", ""), ("1\"=60'|1/720", "1\"=60'", ""), + ('1/64"=1\'-0"|1/768', '1/64"=1\'-0"', ""), ("1\"=70'|1/840", "1\"=70'", ""), ("1\"=80'|1/960", "1\"=80'", ""), ("1\"=90'|1/1080", "1\"=90'", ""), ("1\"=100'|1/1200", "1\"=100'", ""), + ('1/128"=1\'-0"|1/1536', '1/128"=1\'-0"', ""), ("1\"=150'|1/1800", "1\"=150'", ""), ("1\"=200'|1/2400", "1\"=200'", ""), ("1\"=300'|1/3600", "1\"=300'", ""),