mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-28 07:49:59 +00:00
Bonsai: add "Select Shared Annotations" operator
New bim.select_shared_annotations selects every visible annotation that is shared across more than one drawing (len(get_annotation_drawings) > 1), respecting viewport visibility, and reports the count. A select button is added next to the add button in the annotation Drawings panel so all shared annotations can be grabbed in one click. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -106,6 +106,7 @@ classes = (
|
||||
operator.SelectAllDrawings,
|
||||
operator.SelectAllSheets,
|
||||
operator.SelectAssignedProduct,
|
||||
operator.SelectSharedAnnotations,
|
||||
operator.SelectSimilarTextLiteralValue,
|
||||
operator.ToggleTargetView,
|
||||
operator.OpenDocumentationWebUi,
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user