mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Fixing bug with changing text size #3159
Bug appeared after 046940f but it was there before - it was just kind of compensated by the other bug.
Because of that bug blender text size value was reupdated before saving it to pset therefore pset never received a new value.
Also added some refactor, planned to write some test to get this error covered.
This commit is contained in:
@@ -242,14 +242,12 @@ class DecoratorData:
|
||||
# use `regular` as default
|
||||
|
||||
# get font size
|
||||
if classes := pset_data.get("Classes", None):
|
||||
classes_split = classes.split()
|
||||
# prioritize smaller font sizes just like in svg
|
||||
font_size_type = next(
|
||||
(font_size_type for font_size_type in FONT_SIZES if font_size_type in classes_split), "regular"
|
||||
)
|
||||
else:
|
||||
font_size_type = "regular"
|
||||
classes = pset_data.get("Classes", None) or "regular"
|
||||
classes_split = classes.split()
|
||||
# prioritize smaller font sizes just like in svg
|
||||
font_size_type = next(
|
||||
(font_size_type for font_size_type in FONT_SIZES if font_size_type in classes_split), "regular"
|
||||
)
|
||||
font_size = FONT_SIZES[font_size_type]
|
||||
|
||||
# get symbol
|
||||
|
||||
@@ -28,8 +28,8 @@ def disable_editing_text(drawing, obj=None):
|
||||
|
||||
def edit_text(drawing, obj=None):
|
||||
drawing.synchronise_ifc_and_text_attributes(obj)
|
||||
drawing.update_text_value(obj)
|
||||
drawing.update_text_size_pset(obj)
|
||||
drawing.update_text_value(obj)
|
||||
drawing.disable_editing_text(obj)
|
||||
|
||||
|
||||
|
||||
@@ -759,12 +759,7 @@ class Drawing(blenderbim.core.tool.Drawing):
|
||||
props = obj.BIMTextProperties
|
||||
|
||||
literals = cls.get_text_literal(obj, return_list=True)
|
||||
if not literals:
|
||||
props.literals.clear()
|
||||
return
|
||||
|
||||
cls.import_text_attributes(obj)
|
||||
|
||||
for i, literal in enumerate(literals):
|
||||
product = cls.get_assigned_product(tool.Ifc.get_entity(obj))
|
||||
props.literals[i].value = cls.replace_text_literal_variables(literal.Literal, product)
|
||||
|
||||
@@ -36,8 +36,8 @@ class TestDisableEditingText:
|
||||
class TestEditText:
|
||||
def test_run(self, ifc, drawing):
|
||||
drawing.synchronise_ifc_and_text_attributes("obj").should_be_called()
|
||||
drawing.update_text_value("obj").should_be_called()
|
||||
drawing.update_text_size_pset("obj").should_be_called()
|
||||
drawing.update_text_value("obj").should_be_called()
|
||||
drawing.disable_editing_text("obj").should_be_called()
|
||||
subject.edit_text(drawing, obj="obj")
|
||||
|
||||
|
||||
@@ -599,9 +599,16 @@ class TestShowDecorations(NewFile):
|
||||
class TestUpdateTextValue(NewFile):
|
||||
def test_updating_arbitrary_strings(self):
|
||||
TestGetTextLiteral().test_run()
|
||||
ifc = tool.Ifc.get()
|
||||
|
||||
obj = bpy.data.objects.get("Object")
|
||||
subject.update_text_value(obj)
|
||||
assert obj.BIMTextProperties.literals[0].value == "Literal"
|
||||
literal = obj.BIMTextProperties.literals[0]
|
||||
|
||||
assert obj.BIMTextProperties.font_size == "2.5"
|
||||
assert literal.value == "Literal"
|
||||
assert literal.box_alignment[:] == tuple([False] * 6 + [True] + [False] * 2)
|
||||
assert literal.ifc_definition_id == ifc.by_type("IfcTextLiteralWithExtent")[0].id()
|
||||
|
||||
def test_using_attribute_variables(self):
|
||||
TestGetTextLiteral().test_run()
|
||||
@@ -632,3 +639,7 @@ class TestUpdateTextValue(NewFile):
|
||||
|
||||
subject.update_text_value(obj)
|
||||
assert obj.BIMTextProperties.literals[0].value == "Foo Baz Bar"
|
||||
|
||||
# TODO: implement
|
||||
def test_update_text_font_size(self):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user