From 67ae9fced080b881eea8c2e3a2e4856e3d80a99b Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 20 Jun 2025 18:18:40 +0500 Subject: [PATCH] bim.extend_walls_to_polyline_point - fix poll errors selecting non-ifc objects E.g. ``` File "\bonsai\bim\module\model\wall.py", line 142, in poll if not tool.Ifc.get_entity(obj).is_a("IfcWall"): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'is_a' ``` --- src/bonsai/bonsai/bim/module/model/wall.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/model/wall.py b/src/bonsai/bonsai/bim/module/model/wall.py index bae7e3cb72..742b8734a1 100644 --- a/src/bonsai/bonsai/bim/module/model/wall.py +++ b/src/bonsai/bonsai/bim/module/model/wall.py @@ -136,13 +136,12 @@ class ExtendWallsToPolylinePoint(bpy.types.Operator, PolylineOperator, tool.Ifc. @classmethod def poll(cls, context): - is_view_3d = context.space_data.type == "VIEW_3D" - walls = True + if not (space := context.space_data) or space.type != "VIEW_3D": + return False for obj in context.selected_objects: - if not tool.Ifc.get_entity(obj).is_a("IfcWall"): - walls = False - - return bool(context.selected_objects) and is_view_3d and walls + if not (element := tool.Ifc.get_entity(obj)) or not element.is_a("IfcWall"): + return False + return bool(context.selected_objects) def __init__(self): super().__init__()