diff --git a/src/bonsai/bonsai/bim/module/drawing/data.py b/src/bonsai/bonsai/bim/module/drawing/data.py index d7ea7b75af..7730dcde09 100644 --- a/src/bonsai/bonsai/bim/module/drawing/data.py +++ b/src/bonsai/bonsai/bim/module/drawing/data.py @@ -322,7 +322,7 @@ class DecoratorData: symbol = tool.Drawing.get_annotation_symbol(element) # get newline_at - newline_at = pset_data.get('Newline_At', 0) + newline_at = pset_data.get("Newline_At", 0) # other attributes props_literals = props.literals diff --git a/src/bonsai/bonsai/bim/module/drawing/decoration.py b/src/bonsai/bonsai/bim/module/drawing/decoration.py index d0d4c7e4f1..e4b3f702d4 100644 --- a/src/bonsai/bonsai/bim/module/drawing/decoration.py +++ b/src/bonsai/bonsai/bim/module/drawing/decoration.py @@ -609,7 +609,7 @@ class BaseDecorator: text = literal_data["CurrentValue"] if newline_at != 0: - text = helper.add_newline_between_words (text, newline_at) + text = helper.add_newline_between_words(text, newline_at) multiple_lines = text.split("\n") @@ -629,8 +629,6 @@ class BaseDecorator: line_i += 1 if not reverse_lines_order else -1 - - class DimensionDecorator(BaseDecorator): """Decorator for dimension objects - each edge of a segment with arrow diff --git a/src/bonsai/bonsai/bim/module/drawing/helper.py b/src/bonsai/bonsai/bim/module/drawing/helper.py index 1d5c7aa0d1..a307dc7ce0 100644 --- a/src/bonsai/bonsai/bim/module/drawing/helper.py +++ b/src/bonsai/bonsai/bim/module/drawing/helper.py @@ -426,12 +426,12 @@ def add_newline_between_words(text, newline_at): if end >= len(text): # If we're at the end of the string result.append(text[start:]) break - + # Look for the nearest space around the newline_at limit - space_index = text.rfind(' ', start, end) # Try to break before newline_at + space_index = text.rfind(" ", start, end) # Try to break before newline_at if space_index == -1: # No space found, force a break at newline_at - space_index = text.find(' ', end) # Try to break after newline_at - + space_index = text.find(" ", end) # Try to break after newline_at + if space_index == -1: # If there's still no space, take the rest of the text result.append(text[start:]) break @@ -440,4 +440,4 @@ def add_newline_between_words(text, newline_at): result.append(text[start:space_index]) start = space_index + 1 # Skip the space itself - return '\n'.join(result) \ No newline at end of file + return "\n".join(result) diff --git a/src/bonsai/bonsai/bim/module/drawing/operator.py b/src/bonsai/bonsai/bim/module/drawing/operator.py index 6bc79202f8..4f671c8e10 100644 --- a/src/bonsai/bonsai/bim/module/drawing/operator.py +++ b/src/bonsai/bonsai/bim/module/drawing/operator.py @@ -1339,15 +1339,15 @@ class CreateDrawing(bpy.types.Operator): def move_elements_to_top(self, root): group = root.find("{http://www.w3.org/2000/svg}g") - + # TODO: Make this an assignable preference - classes_to_move = ['IfcColumn', 'IfcBeam', 'EPsetStatusStatus-NEW'] - + classes_to_move = ["IfcColumn", "IfcBeam", "EPsetStatusStatus-NEW"] + # Iterate through classes in order of preference for class_name in classes_to_move: xpath_query = f".//svg:g[contains(@class, '{class_name}')]" elements_to_move = root.xpath(xpath_query, namespaces={"svg": "http://www.w3.org/2000/svg"}) - + # Move each element to the end of the group (effectively placing them at the top visually) for element in elements_to_move: element.getparent().remove(element) diff --git a/src/bonsai/bonsai/bim/module/drawing/svgwriter.py b/src/bonsai/bonsai/bim/module/drawing/svgwriter.py index 01e6bfdcff..da1c7f074d 100644 --- a/src/bonsai/bonsai/bim/module/drawing/svgwriter.py +++ b/src/bonsai/bonsai/bim/module/drawing/svgwriter.py @@ -852,7 +852,7 @@ class SvgWriter: classes_str, fill_bg=fill_bg, line_number_start=line_number, - newline_at = newline_at, + newline_at=newline_at, ) for tag in text_tags: self.svg.add(tag) @@ -1406,7 +1406,7 @@ class SvgWriter: text_tag = self.svg.text("", **text_kwargs, **base_text_attrs) text_tags.append(text_tag) if newline_at != 0: - text = helper.add_newline_between_words (text, newline_at) + text = helper.add_newline_between_words(text, newline_at) text_lines = text.replace("\\n", "\n").split("\n") text_lines = text_lines if multiline_to_bottom else text_lines[::-1] diff --git a/src/bonsai/bonsai/tool/drawing.py b/src/bonsai/bonsai/tool/drawing.py index 06c07c87a2..8fa654b8f1 100644 --- a/src/bonsai/bonsai/tool/drawing.py +++ b/src/bonsai/bonsai/tool/drawing.py @@ -1044,6 +1044,7 @@ class Drawing(bonsai.core.tool.Drawing): pset=pset, properties={"Newline_At": newline_at}, ) + # TODO below this point is highly experimental prototype code with no tests @classmethod