From 69a4be68e8bb4745ae4530eb60e283a36887eebf Mon Sep 17 00:00:00 2001 From: Petru Conduraru Date: Thu, 9 Jul 2026 13:24:57 +0300 Subject: [PATCH] Bonsai: fall back to adaptive units for unsupported SI prefixes #8074 Project loading set scene length_unit to f"{Prefix}METERS", but Blender's enum only defines KILOMETERS, CENTIMETERS, MILLIMETERS and MICROMETERS. A model with a DECIMETRE (or HECTO/DECA/etc.) length unit therefore raised on the enum assignment and the file failed to open. Guard with the set of supported values and fall back to ADAPTIVE display for the rest. Co-Authored-By: Claude Fable 5 --- src/bonsai/bonsai/bim/import_ifc.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bonsai/bonsai/bim/import_ifc.py b/src/bonsai/bonsai/bim/import_ifc.py index 81d577026a..06f4c4afff 100644 --- a/src/bonsai/bonsai/bim/import_ifc.py +++ b/src/bonsai/bonsai/bim/import_ifc.py @@ -980,8 +980,13 @@ class IfcImporter: if unit.Name == "METRE": if not unit.Prefix: bpy.context.scene.unit_settings.length_unit = "METERS" - else: + elif f"{unit.Prefix}METERS" in ("KILOMETERS", "CENTIMETERS", "MILLIMETERS", "MICROMETERS"): bpy.context.scene.unit_settings.length_unit = f"{unit.Prefix}METERS" + else: + # Blender's length_unit enum has no entry for other + # SI prefixes (e.g. DECIMETERS), so fall back to + # adaptive display instead of failing to open. + bpy.context.scene.unit_settings.length_unit = "ADAPTIVE" else: bpy.context.scene.unit_settings.system = "IMPERIAL" name = unit.Name.lower()