Bonsai: clean error instead of a traceback for Extend To Underside (#7454)

Selecting a non-wall pair (e.g. a column and a slab) and pressing Shift+E
surfaced a developer Python traceback. Hotkey.hotkey_S_E's catch-all else
branch unconditionally called bpy.ops.bim.extend_walls_to_underside(); when
the selection contains no path-connectable wall, that nested operator
reports an ERROR and returns CANCELLED, which - invoked via bpy.ops from
inside the outer operator - raises RuntimeError as an unhandled exception,
so the user saw a full traceback.

Guard the selection with the operator's own predicate
(tool.Parametric.is_path_connectable_wall): dispatch to
extend_walls_to_underside only when at least one wall and one other element
are selected, otherwise report a clean end-user error. Mirrors the pattern
already used by hotkey_S_X (align). The valid wall + target path is
unchanged.

This hardens the reported crash. It does not implement extending a column
to a slab underside, which is a separate feature request in the same issue.

Verified live in headless Blender: a column + slab selection produced the
reported traceback before and now yields a single clean error message with
no workspace.py / extend_walls_to_underside frames.

Generated with the assistance of an AI coding tool.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Petru Conduraru
2026-07-12 09:55:19 +03:00
parent 0b7e25a3ef
commit 7e79f9911d
@@ -1280,7 +1280,22 @@ class Hotkey(bpy.types.Operator, tool.Ifc.Operator):
bpy.ops.bim.extend_profile(join_type="T")
else:
bpy.ops.bim.extend_walls_to_underside()
# Extend LAYER2 walls to the underside of another selected element.
# Guard the selection here so an invalid combination (e.g. a column
# and a slab, with no wall involved) reports a clean end-user error
# instead of surfacing the nested operator's ERROR as a developer
# traceback (see #7454).
walls = [
obj
for obj in bpy.context.selected_objects
if (element := tool.Ifc.get_entity(obj)) and tool.Parametric.is_path_connectable_wall(element)
]
if walls and len(bpy.context.selected_objects) > len(walls):
bpy.ops.bim.extend_walls_to_underside()
else:
self.report(
{"ERROR"}, "Please select at least one LAYER2 element and at least one other IFC element"
)
def hotkey_S_F(self):
if not bpy.context.selected_objects: