mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 02:31:09 +00:00
#1153 Fix newlines in text literals and smart tags in SVGs
This commit is contained in:
@@ -67,7 +67,7 @@ class SheetBuilder:
|
|||||||
drawing_dir = os.path.join(self.data_dir, "diagrams")
|
drawing_dir = os.path.join(self.data_dir, "diagrams")
|
||||||
sheet_path = os.path.join(sheet_dir, sheet_name + ".svg")
|
sheet_path = os.path.join(sheet_dir, sheet_name + ".svg")
|
||||||
drawing_path = os.path.join(drawing_dir, filename + ".svg")
|
drawing_path = os.path.join(drawing_dir, filename + ".svg")
|
||||||
underlay_path = os.path.join(drawing_dir, filename + ".png")
|
underlay_path = os.path.join(drawing_dir, filename + "-underlay.png")
|
||||||
|
|
||||||
if not os.path.isfile(sheet_path):
|
if not os.path.isfile(sheet_path):
|
||||||
raise FileNotFoundError
|
raise FileNotFoundError
|
||||||
|
|||||||
@@ -544,7 +544,7 @@ class SvgWriter:
|
|||||||
|
|
||||||
if text_obj.BIMTextProperties.symbol != "None":
|
if text_obj.BIMTextProperties.symbol != "None":
|
||||||
self.svg.add(
|
self.svg.add(
|
||||||
self.svg.use("#{}".format(text_obj.BIMTextProperties.symbol), insert=tuple(text_position * self.scale))
|
self.svg.use(f"#{text_obj.BIMTextProperties.symbol}", insert=tuple(text_position * self.scale))
|
||||||
)
|
)
|
||||||
|
|
||||||
if text_literal.BoxAlignment == "top-left":
|
if text_literal.BoxAlignment == "top-left":
|
||||||
@@ -575,11 +575,15 @@ class SvgWriter:
|
|||||||
alignment_baseline = "baseline"
|
alignment_baseline = "baseline"
|
||||||
text_anchor = "end"
|
text_anchor = "end"
|
||||||
|
|
||||||
text_body = text_literal.Literal
|
literal = text_literal.Literal
|
||||||
if text_obj.name in self.annotations.get("template_variables", {}):
|
|
||||||
text_body = pystache.render(text_body, self.annotations["template_variables"][text_obj.name])
|
|
||||||
|
|
||||||
for line_number, text_line in enumerate(text_body.split("\n")):
|
product = tool.Drawing.get_text_product(element)
|
||||||
|
selector = ifcopenshell.util.selector.Selector
|
||||||
|
variables = {}
|
||||||
|
for variable in re.findall("{{.*?}}", literal):
|
||||||
|
literal = literal.replace(variable, selector.get_element_value(product, variable[2:-2]) or "")
|
||||||
|
|
||||||
|
for line_number, text_line in enumerate(literal.replace("\\n", "\n").split("\n")):
|
||||||
self.svg.add(
|
self.svg.add(
|
||||||
self.svg.text(
|
self.svg.text(
|
||||||
text_line,
|
text_line,
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
name = document.Identification or "X"
|
name = document.Identification or "X"
|
||||||
else:
|
else:
|
||||||
name = document.DocumentId or "X"
|
name = document.DocumentId or "X"
|
||||||
name += " - " + document.Name or "Unnamed"
|
name += " - " + (document.Name or "Unnamed")
|
||||||
return name
|
return name
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user