Fix #2883. Regression in text in drawings.

This commit is contained in:
Dion Moult
2023-03-21 12:31:32 +11:00
parent 8bae2984e1
commit d503a4b50b
2 changed files with 13 additions and 8 deletions
@@ -664,7 +664,8 @@ class SvgWriter:
# this is why we apply "font-size: 0;" to the text tag to remove those spaces
# and add clases to the tspan tags
# ref: https://github.com/IfcOpenShell/IfcOpenShell/issues/2833#issuecomment-1471584960
text = text_obj.BIMTextProperties.value
product = tool.Drawing.get_assigned_product(element)
text = tool.Drawing.replace_text_literal_variables(text_literal.Literal, product)
text_tag = self.svg.text(
"",
**{
+11 -7
View File
@@ -540,14 +540,8 @@ class Drawing(blenderbim.core.tool.Drawing):
ifc_literal = cls.get_text_literal(obj)
if not ifc_literal:
return
value = ifc_literal.Literal
product = cls.get_assigned_product(tool.Ifc.get_entity(obj))
if product:
for variable in re.findall("{{.*?}}", value):
value = value.replace(
variable, str(ifcopenshell.util.selector.get_element_value(product, variable[2:-2]) or "")
)
props.value = value
props.value = cls.replace_text_literal_variables(ifc_literal.Literal, product)
@classmethod
def update_text_size_pset(cls, obj):
@@ -959,6 +953,16 @@ class Drawing(blenderbim.core.tool.Drawing):
b_tree = mathutils.bvhtree.BVHTree.FromPolygons(b_block["verts"], b_block["faces"])
return bool(a_tree.overlap(b_tree))
@classmethod
def replace_text_literal_variables(cls, text, product):
if not product:
return text
for variable in re.findall("{{.*?}}", text):
text = text.replace(
variable, str(ifcopenshell.util.selector.get_element_value(product, variable[2:-2]) or "")
)
return text
@classmethod
def sync_object_representation(cls, obj):
bpy.ops.bim.update_representation(obj=obj.name)