Fix bug where updating type text literals didn't propagate and formatting rounding null values wasn't handled.

This commit is contained in:
Dion Moult
2024-01-10 14:42:14 +11:00
parent a33f30e8ce
commit 6ea1e378c5
2 changed files with 26 additions and 7 deletions
+25 -6
View File
@@ -889,13 +889,32 @@ class Drawing(blenderbim.core.tool.Drawing):
@classmethod
def update_text_value(cls, obj):
props = obj.BIMTextProperties
element = tool.Ifc.get_entity(obj)
if element.is_a("IfcTypeProduct"):
objs = [obj]
for occurrence in ifcopenshell.util.element.get_types(element):
obj = tool.Ifc.get_object(occurrence)
if obj:
objs.append(obj)
else:
objs = []
element_type = ifcopenshell.util.element.get_type(element)
if element_type and element_type.RepresentationMaps:
obj = tool.Ifc.get_object(element_type)
if obj:
objs.append(obj)
for occurrence in ifcopenshell.util.element.get_types(element_type):
obj = tool.Ifc.get_object(occurrence)
if obj:
objs.append(obj)
literals = cls.get_text_literal(obj, return_list=True)
cls.import_text_attributes(obj)
for i, literal in enumerate(literals):
product = cls.get_assigned_product(tool.Ifc.get_entity(obj)) or tool.Ifc.get_entity(obj)
props.literals[i].value = cls.replace_text_literal_variables(literal.Literal, product)
for obj in objs:
props = obj.BIMTextProperties
literals = cls.get_text_literal(obj, return_list=True)
cls.import_text_attributes(obj)
for i, literal in enumerate(literals):
product = cls.get_assigned_product(tool.Ifc.get_entity(obj)) or tool.Ifc.get_entity(obj)
props.literals[i].value = cls.replace_text_literal_variables(literal.Literal, product)
@classmethod
def update_text_size_pset(cls, obj):
@@ -195,7 +195,7 @@ class FormatTransformer(lark.Transformer):
return str(args[0])[int(args[1]) :]
def round(self, args):
value = Decimal(args[0] or 0.0)
value = Decimal(0.0 if args[0] == "None" else args[0] or 0.0)
nearest = Decimal(args[1])
result = round(value / nearest) * nearest
if nearest % 1 == 0: