mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-30 00:23:14 +00:00
Multiple literals in 1 Ifc Text + aggregated text annotations
Added option to store multiple literals inside 1 Ifc text object. If multiple literals share the same `BoxAlignment` then only the first one will be displayed in viewport to prevent visual clutter (although added small asterisk symbol to indicate that there are still multiple literals). Added option for aggregated text annotations. Example - "door-tag" symbol. If you create text, specify "door-tag" symbol in EPset_Annotation.Symbol \and add two literals to it then they'll automatically will fit to that door-tag in the svg drawing (https://i.imgur.com/OXaIlWe.png). The way it works - you define symbol in symbols.svg (or in your own symbols svg file) and then add the `<text>` fields where text from literals will fit right in. The imporant note: `<text>` tag must have attribute `data-type="text-template"` for it to work. For example: `<text text-anchor="middle" dominant-baseline="middle" data-type="text-template"></text>`
This commit is contained in:
@@ -35,13 +35,11 @@ class TestDisableEditingText:
|
||||
|
||||
class TestEditText:
|
||||
def test_run(self, ifc, drawing):
|
||||
drawing.get_text_literal("obj").should_be_called().will_return("text")
|
||||
drawing.export_text_literal_attributes("obj").should_be_called().will_return("attributes")
|
||||
ifc.run("drawing.edit_text_literal", text_literal="text", attributes="attributes").should_be_called()
|
||||
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.disable_editing_text("obj").should_be_called()
|
||||
subject.edit_text(ifc, drawing, obj="obj")
|
||||
subject.edit_text(drawing, obj="obj")
|
||||
|
||||
|
||||
class TestEnableEditingAssignedProduct:
|
||||
|
||||
@@ -204,11 +204,11 @@ class TestEnsureUniqueIdentification(NewFile):
|
||||
class TestExportTextLiteralAttributes(NewFile):
|
||||
def test_run(self):
|
||||
TestImportTextAttributes().test_run()
|
||||
assert subject.export_text_literal_attributes(bpy.data.objects.get("Object")) == {
|
||||
assert subject.export_text_literal_attributes(bpy.data.objects.get("Object")) == [{
|
||||
"Literal": "Literal",
|
||||
"Path": "RIGHT",
|
||||
"BoxAlignment": "bottom-left",
|
||||
}
|
||||
}]
|
||||
|
||||
|
||||
class TestGetAnnotationContext(NewFile):
|
||||
@@ -433,6 +433,7 @@ class TestGetTextLiteral(NewFile):
|
||||
item = ifc.createIfcTextLiteralWithExtent(Literal="Literal", Path="RIGHT", BoxAlignment="bottom-left")
|
||||
representation = ifc.createIfcShapeRepresentation(ContextOfItems=context, Items=[item])
|
||||
element.Representation.Representations = [representation]
|
||||
element.ObjectType = "TEXT" # TODO: double check if it's valid to set this
|
||||
tool.Ifc.link(element, obj)
|
||||
assert subject.get_text_literal(obj) == item
|
||||
|
||||
@@ -520,12 +521,13 @@ class TestImportTextAttributes(NewFile):
|
||||
item = ifc.createIfcTextLiteralWithExtent(Literal="Literal", Path="RIGHT", BoxAlignment="bottom-left")
|
||||
representation = ifc.createIfcShapeRepresentation(ContextOfItems=context, Items=[item])
|
||||
element.Representation.Representations = [representation]
|
||||
element.ObjectType = "TEXT" # TODO: double check if it's valid to set this
|
||||
tool.Ifc.link(element, obj)
|
||||
subject.import_text_attributes(obj)
|
||||
props = obj.BIMTextProperties
|
||||
assert props.attributes.get("Literal").string_value == "Literal"
|
||||
assert props.attributes.get("Path").enum_value == "RIGHT"
|
||||
assert props.attributes.get("BoxAlignment").string_value == "bottom-left"
|
||||
literal_props = obj.BIMTextProperties.literals[0]
|
||||
assert literal_props.attributes.get("Literal").string_value == "Literal"
|
||||
assert literal_props.attributes.get("Path").enum_value == "RIGHT"
|
||||
assert literal_props.attributes.get("BoxAlignment").string_value == "bottom-left"
|
||||
|
||||
|
||||
class TestImportAssignedProduct(NewFile):
|
||||
@@ -596,7 +598,7 @@ class TestUpdateTextValue(NewFile):
|
||||
TestGetTextLiteral().test_run()
|
||||
obj = bpy.data.objects.get("Object")
|
||||
subject.update_text_value(obj)
|
||||
assert obj.BIMTextProperties.value == "Literal"
|
||||
assert obj.BIMTextProperties.literals[0].value == "Literal"
|
||||
|
||||
def test_using_attribute_variables(self):
|
||||
TestGetTextLiteral().test_run()
|
||||
@@ -610,7 +612,7 @@ class TestUpdateTextValue(NewFile):
|
||||
ifc.by_type("IfcTextLiteralWithExtent")[0].Literal = "Foo {{Name}} Bar"
|
||||
|
||||
subject.update_text_value(obj)
|
||||
assert obj.BIMTextProperties.value == "Foo Baz Bar"
|
||||
assert obj.BIMTextProperties.literals[0].value == "Foo Baz Bar"
|
||||
|
||||
def test_using_property_variables(self):
|
||||
TestGetTextLiteral().test_run()
|
||||
@@ -626,4 +628,4 @@ class TestUpdateTextValue(NewFile):
|
||||
ifc.by_type("IfcTextLiteralWithExtent")[0].Literal = "Foo {{Custom_Pset.Key}} Bar"
|
||||
|
||||
subject.update_text_value(obj)
|
||||
assert obj.BIMTextProperties.value == "Foo Baz Bar"
|
||||
assert obj.BIMTextProperties.literals[0].value == "Foo Baz Bar"
|
||||
|
||||
Reference in New Issue
Block a user