mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
tweaks to 812e3dc6df
This commit is contained in:
@@ -421,6 +421,14 @@ def add_newline_between_words(text, newline_at):
|
||||
start = 0
|
||||
|
||||
while start < len(text):
|
||||
# Find the next newline character if present
|
||||
newline_index = text.find("\n", start)
|
||||
if newline_index != -1 and newline_index < start + newline_at:
|
||||
# If a newline is found within the current range
|
||||
result.append(text[start:newline_index]) # Add text up to the newline
|
||||
start = newline_index + 1 # Move past the newline
|
||||
continue
|
||||
|
||||
# Find the end index considering the limit newline_at
|
||||
end = start + newline_at
|
||||
if end >= len(text): # If we're at the end of the string
|
||||
@@ -441,3 +449,5 @@ def add_newline_between_words(text, newline_at):
|
||||
start = space_index + 1 # Skip the space itself
|
||||
|
||||
return "\n".join(result)
|
||||
|
||||
|
||||
|
||||
@@ -509,7 +509,7 @@ class Literal(PropertyGroup):
|
||||
return self.get("box_alignment", DEFAULT_BOX_ALIGNMENT)
|
||||
|
||||
attributes: CollectionProperty(name="Attributes", type=Attribute)
|
||||
# Current text value with evaluated experessions stored in `value`.
|
||||
# Current text value with evaluated expressions stored in `value`.
|
||||
# The original (Literal) value stored in `attributes['Literal']`
|
||||
# and can be accessed with `get_text()`
|
||||
value: StringProperty(name="Value", default="TEXT")
|
||||
|
||||
@@ -807,6 +807,7 @@ class SvgWriter:
|
||||
fill_bg = "fill-bg" in classes
|
||||
|
||||
symbol = tool.Drawing.get_annotation_symbol(element)
|
||||
newline_at = tool.Drawing.get_newline_at(element)
|
||||
template_text_fields = []
|
||||
if symbol:
|
||||
symbol_transform = self.get_symbol_transform(text_position_svg_str, angle, text_obj)
|
||||
@@ -841,7 +842,7 @@ class SvgWriter:
|
||||
self.draw_symbol(symbol, symbol_transform)
|
||||
|
||||
line_number = 0
|
||||
newline_at = text_obj.BIMTextProperties.newline_at
|
||||
|
||||
for text_literal in text_literals:
|
||||
text = tool.Drawing.replace_text_literal_variables(text_literal.Literal, product or element)
|
||||
text_tags = self.create_text_tag(
|
||||
|
||||
@@ -910,6 +910,7 @@ class Drawing(bonsai.core.tool.Drawing):
|
||||
|
||||
text_data = DecoratorData.get_ifc_text_data(obj)
|
||||
props.font_size = str(text_data["FontSize"])
|
||||
props.newline_at = text_data['Newline_At']
|
||||
|
||||
@classmethod
|
||||
def import_assigned_product(cls, obj: bpy.types.Object) -> None:
|
||||
@@ -1692,6 +1693,12 @@ class Drawing(bonsai.core.tool.Drawing):
|
||||
symbol = ifcopenshell.util.element.get_pset(element, "EPset_AnnotationSurveyArea", "PointType")
|
||||
return symbol
|
||||
|
||||
@classmethod
|
||||
def get_newline_at(cls, element: ifcopenshell.entity_instance) -> Union[int, 0]:
|
||||
newline_at = ifcopenshell.util.element.get_pset(element, "EPset_Annotation", "Newline_At")
|
||||
return newline_at
|
||||
|
||||
|
||||
@classmethod
|
||||
def has_linework(cls, drawing: ifcopenshell.entity_instance) -> bool:
|
||||
return ifcopenshell.util.element.get_psets(drawing).get("EPset_Drawing", {}).get("HasLinework", False)
|
||||
|
||||
Reference in New Issue
Block a user