From bea9f42f878df14566c52331118818bb5468e9c6 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 15 May 2025 17:52:55 +0500 Subject: [PATCH] Annotator.add_text - remove ancient dead code It was deprecated a while ago in 43869c3, when we stopped using curves for text annotations. bim.resize_text was also using curve annotations and now also was unused --- .../bonsai/bim/module/drawing/__init__.py | 1 - .../bonsai/bim/module/drawing/annotation.py | 46 ------------------- .../bonsai/bim/module/drawing/operator.py | 13 ------ 3 files changed, 60 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/drawing/__init__.py b/src/bonsai/bonsai/bim/module/drawing/__init__.py index d1915a4b2d..7e3be31e36 100644 --- a/src/bonsai/bonsai/bim/module/drawing/__init__.py +++ b/src/bonsai/bonsai/bim/module/drawing/__init__.py @@ -83,7 +83,6 @@ classes = ( operator.RemoveSchedule, operator.RemoveSheet, operator.RemoveTextLiteral, - operator.ResizeText, operator.SaveDrawingStyle, operator.SaveDrawingStylesData, operator.SelectAllDrawings, diff --git a/src/bonsai/bonsai/bim/module/drawing/annotation.py b/src/bonsai/bonsai/bim/module/drawing/annotation.py index d41c901e4d..9589b9ac00 100644 --- a/src/bonsai/bonsai/bim/module/drawing/annotation.py +++ b/src/bonsai/bonsai/bim/module/drawing/annotation.py @@ -29,52 +29,6 @@ from typing import Optional class Annotator: - @staticmethod - def add_text(related_element: Optional[ifcopenshell.entity_instance] = None) -> bpy.types.Object: - curve = bpy.data.curves.new(type="FONT", name="Text") - curve.body = "TEXT" - obj = bpy.data.objects.new("Text", curve) - obj.matrix_world = bpy.context.scene.camera.matrix_world - if related_element is None: - location, _, _, _ = Annotator.get_placeholder_coords(bpy.context) - else: - curve.BIMAssignedProductProperties.related_element = related_element - location = related_element.location - obj.location = location - obj.hide_render = True - font = bpy.data.fonts.get("OpenGost TypeB TT") - if not font: - font = bpy.data.fonts.load( - tool.Blender.get_data_dir_path(Path("fonts") / "OpenGost Type B TT.ttf").__str__() - ) - font.name = "OpenGost Type B TT" - curve.font = font - props = tool.Drawing.get_text_props(obj) - props.font_size = "2.5" - collection = tool.Blender.get_object_bim_props(bpy.context.scene.camera).collection - collection.objects.link(obj) - Annotator.resize_text(obj) - return obj - - @staticmethod - def resize_text(text_obj: bpy.types.Object) -> None: - camera = None - group = tool.Drawing.get_drawing_group(tool.Ifc.get_entity(text_obj)) - for element in tool.Drawing.get_drawing_elements(group): - if element.is_a("IfcAnnotation") and element.ObjectType == "DRAWING": - camera = tool.Ifc.get_object(element) - break - if not camera: - return - # This is a magic number for OpenGost - font_size = 1.6 / 1000 - props = tool.Drawing.get_text_props(text_obj) - font_size *= float(props.font_size) - - font_size /= tool.Drawing.get_scale_ratio(tool.Drawing.get_diagram_scale(camera)["Scale"]) - - text_obj.data.size = font_size - @staticmethod def add_line_to_annotation( obj: bpy.types.Object, co1: Optional[Vector] = None, co2: Optional[Vector] = None diff --git a/src/bonsai/bonsai/bim/module/drawing/operator.py b/src/bonsai/bonsai/bim/module/drawing/operator.py index 2cd339c859..39b5617b24 100644 --- a/src/bonsai/bonsai/bim/module/drawing/operator.py +++ b/src/bonsai/bonsai/bim/module/drawing/operator.py @@ -2241,19 +2241,6 @@ class SelectDocIfcFile(bpy.types.Operator, ImportHelper): return {"FINISHED"} -class ResizeText(bpy.types.Operator): - bl_idname = "bim.resize_text" - bl_label = "Resize Text" - bl_options = {"REGISTER", "UNDO"} - # TODO: check undo redo - - def execute(self, context): - for obj in tool.Blender.get_object_bim_props(context.scene.camera).collection.objects: - if isinstance(obj.data, bpy.types.TextCurve): - annotation.Annotator.resize_text(obj) - return {"FINISHED"} - - class RemoveDrawing(bpy.types.Operator, tool.Ifc.Operator): bl_idname = "bim.remove_drawing" bl_label = "Remove Drawing"