diff --git a/src/bonsai/bonsai/bim/module/drawing/__init__.py b/src/bonsai/bonsai/bim/module/drawing/__init__.py index 2f35de2d86..debc1621b6 100644 --- a/src/bonsai/bonsai/bim/module/drawing/__init__.py +++ b/src/bonsai/bonsai/bim/module/drawing/__init__.py @@ -106,6 +106,7 @@ classes = ( operator.SelectAllDrawings, operator.SelectAllSheets, operator.SelectAssignedProduct, + operator.SelectSharedAnnotations, operator.SelectSimilarTextLiteralValue, operator.ToggleTargetView, operator.OpenDocumentationWebUi, diff --git a/src/bonsai/bonsai/bim/module/drawing/operator.py b/src/bonsai/bonsai/bim/module/drawing/operator.py index c31f8e9d57..574ff627ec 100644 --- a/src/bonsai/bonsai/bim/module/drawing/operator.py +++ b/src/bonsai/bonsai/bim/module/drawing/operator.py @@ -2022,6 +2022,37 @@ class RemoveAnnotationFromDrawing(bpy.types.Operator, tool.Ifc.Operator): area.tag_redraw() +class SelectSharedAnnotations(bpy.types.Operator): + bl_idname = "bim.select_shared_annotations" + bl_label = "Select Shared Annotations" + bl_description = "Select every visible annotation that is shared across more than one drawing" + bl_options = {"REGISTER", "UNDO"} + + @classmethod + def poll(cls, context): + return tool.Ifc.get() is not None + + def execute(self, context): + bpy.ops.object.select_all(action="DESELECT") + selected = 0 + active = None + for obj in context.view_layer.objects: + element = tool.Ifc.get_entity(obj) + if not element or not element.is_a("IfcAnnotation") or element.ObjectType == "DRAWING": + continue + if len(tool.Drawing.get_annotation_drawings(element)) <= 1: + continue + if not obj.visible_get(): + continue + obj.select_set(True) + active = active or obj + selected += 1 + if active: + context.view_layer.objects.active = active + self.report({"INFO"}, f"Selected {selected} shared annotation(s).") + return {"FINISHED"} + + class AddSheet(bpy.types.Operator, tool.Ifc.Operator): bl_idname = "bim.add_sheet" bl_label = "Add Sheet" diff --git a/src/bonsai/bonsai/bim/module/drawing/ui.py b/src/bonsai/bonsai/bim/module/drawing/ui.py index 8e6ad047e1..baabb127c1 100644 --- a/src/bonsai/bonsai/bim/module/drawing/ui.py +++ b/src/bonsai/bonsai/bim/module/drawing/ui.py @@ -596,6 +596,7 @@ class BIM_PT_annotation_drawings(Panel): row = self.layout.row(align=True) row.label(text="Shown on drawings:", icon="IMAGE_DATA") + row.operator("bim.select_shared_annotations", icon="RESTRICT_SELECT_OFF", text="") row.operator("bim.add_annotation_to_drawing", icon="ADD", text="") drawings = ProductAssignmentsData.data["annotation_drawings"]