From f158ae7377871b0e3821f9100b84e1401d618508 Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Mon, 1 Jun 2026 15:01:13 -0500 Subject: [PATCH] Fix crash in update_bim_tool_props when selected type isn't a valid ifc_class props.ifc_class is an EnumProperty whose items list only the element/space types present in the model. Assigning element_type.is_a() crashed with `enum "" not found` when the selected element's type wasn't a member (e.g. a raw IfcTypeProduct, or a stale item list mid-rebuild), aborting the post-commit refresh. Wrap the assignment in the same try/except TypeError guard already used for the sibling relating_type_id assignments (added in 233cc344fa). Co-Authored-By: Claude Opus 4.8 --- src/bonsai/bonsai/bim/handler.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bonsai/bonsai/bim/handler.py b/src/bonsai/bonsai/bim/handler.py index ff916bf8a9..47e488b68e 100644 --- a/src/bonsai/bonsai/bim/handler.py +++ b/src/bonsai/bonsai/bim/handler.py @@ -151,7 +151,14 @@ def update_bim_tool_props(): return if is_bim_tool: - props.ifc_class = element_type.is_a() + try: + props.ifc_class = element_type.is_a() + except TypeError: + # ifc_class only lists element/space types present in the model, so an + # unsupported type (e.g. a raw IfcTypeProduct) or a stale item list mid- + # rebuild raises `enum "" not found`. Skip rather than crash the + # handler — it re-fires on the next selection and the panel resyncs. + pass # Only assign when the target enum is the one that lists this type — otherwise # we hit `enum "" not found in (...)` if the user selects an element of a