From 12a374dfb02b996f8824ce3f071143134308af80 Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Sun, 15 Mar 2026 15:03:53 -0500 Subject: [PATCH] Fix manual section/elevation annotation placement in non-plan views Use get_default_annotation_matrix() for manual SECTION annotations so the object is placed in the camera's annotation plane with the correct rotation, matching how auto-generated section annotations are created. Without this, annotations placed in elevation or section camera views had identity rotation, causing the IFC representation to be in the wrong coordinate system and failing to tessellate. Also guard draw_edit_object_interface against non-IFC active objects to prevent AssertionError during toolbar redraws, and skip IFC item edit mode for ELEVATION/SECTION annotation types on placement. --- src/bonsai/bonsai/bim/module/drawing/operator.py | 5 ++++- src/bonsai/bonsai/bim/module/drawing/workspace.py | 3 ++- src/bonsai/bonsai/tool/drawing.py | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/drawing/operator.py b/src/bonsai/bonsai/bim/module/drawing/operator.py index 85efdada02..33879cd088 100644 --- a/src/bonsai/bonsai/bim/module/drawing/operator.py +++ b/src/bonsai/bonsai/bim/module/drawing/operator.py @@ -1784,7 +1784,10 @@ class AddAnnotation(bpy.types.Operator, tool.Ifc.Operator): drawing=drawing, object_type=object_type, relating_type=tool.Ifc.get().by_id(int(props.relating_type_id)) if props.relating_type_id != "0" else None, - enable_editing=True, + # ELEVATION/SECTION annotations use simple empty/line geometry that + # cannot be tessellated by the IFC geometry engine, so skip IFC + # item edit mode for these types. + enable_editing=object_type not in ("ELEVATION", "SECTION"), ) if props.object_type == "IMAGE": bpy.ops.bim.add_reference_image("INVOKE_DEFAULT", existing_object_by_name=obj.name) diff --git a/src/bonsai/bonsai/bim/module/drawing/workspace.py b/src/bonsai/bonsai/bim/module/drawing/workspace.py index 9b7098417d..4cd615e890 100644 --- a/src/bonsai/bonsai/bim/module/drawing/workspace.py +++ b/src/bonsai/bonsai/bim/module/drawing/workspace.py @@ -223,7 +223,8 @@ class AnnotationToolUI: @classmethod def draw_edit_object_interface(cls, context): - if DecoratorData.get_text_data(bpy.context.active_object): + obj = bpy.context.active_object + if tool.Ifc.get_entity(obj) and DecoratorData.get_text_data(obj): add_layout_hotkey_operator(cls.layout, "Edit Text", "S_E", "") @classmethod diff --git a/src/bonsai/bonsai/tool/drawing.py b/src/bonsai/bonsai/tool/drawing.py index 7b58fa0018..60f860ff2e 100644 --- a/src/bonsai/bonsai/tool/drawing.py +++ b/src/bonsai/bonsai/tool/drawing.py @@ -217,7 +217,8 @@ class Drawing(bonsai.core.tool.Drawing): math.radians(90), 4, "X" ) elif object_type == "SECTION": - obj.matrix_world = Matrix.Translation(bpy.context.scene.cursor.location.copy()) + camera = tool.Ifc.get_object(drawing) + obj.matrix_world = cls.get_default_annotation_matrix(camera) obj = annotation.Annotator.add_line_to_annotation(obj) elif object_type != "TEXT": obj = annotation.Annotator.add_line_to_annotation(obj)