mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
black .
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
return "\n".join(result)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user