You can now associate annotations with objects for smart annotations in IFC. See #1153.

This commit is contained in:
Dion Moult
2022-01-14 18:00:08 +11:00
parent 258ca7fb8c
commit f8c7f48674
15 changed files with 311 additions and 73 deletions
+24
View File
@@ -41,3 +41,27 @@ class TestEditText:
drawing.update_text_value("obj").should_be_called()
drawing.disable_editing_text("obj").should_be_called()
subject.edit_text(ifc, drawing, obj="obj")
class TestEnableEditingTextProduct:
def test_run(self, drawing):
drawing.enable_editing_text_product("obj").should_be_called()
drawing.import_text_product("obj").should_be_called()
subject.enable_editing_text_product(drawing, obj="obj")
class TestDisableEditingTextProduct:
def test_run(self, drawing):
drawing.disable_editing_text_product("obj").should_be_called()
subject.disable_editing_text_product(drawing, obj="obj")
class TestEditTextProduct:
def test_run(self, ifc, drawing):
ifc.get_entity("obj").should_be_called().will_return("element")
drawing.get_text_product("element").should_be_called().will_return("existing_product")
ifc.run("drawing.unassign_product", relating_product="existing_product", related_object="element").should_be_called()
ifc.run("drawing.assign_product", relating_product="product", related_object="element").should_be_called()
drawing.update_text_value("obj").should_be_called()
drawing.disable_editing_text_product("obj").should_be_called()
subject.edit_text_product(ifc, drawing, obj="obj", product="product")
+49
View File
@@ -37,6 +37,14 @@ class TestDisableEditingText(NewFile):
assert obj.BIMTextProperties.is_editing == False
class TestDisableEditingTextProduct(NewFile):
def test_run(self):
obj = bpy.data.objects.new("Object", None)
obj.BIMTextProperties.is_editing_product = True
subject.disable_editing_text_product(obj)
assert obj.BIMTextProperties.is_editing_product == False
class TestEnableEditingText(NewFile):
def test_run(self):
obj = bpy.data.objects.new("Object", None)
@@ -44,6 +52,13 @@ class TestEnableEditingText(NewFile):
assert obj.BIMTextProperties.is_editing == True
class TestEnableEditingTextProduct(NewFile):
def test_run(self):
obj = bpy.data.objects.new("Object", None)
subject.enable_editing_text_product(obj)
assert obj.BIMTextProperties.is_editing_product == True
class TestExportTextLiteralAttributes(NewFile):
def test_run(self):
TestImportTextAttributes().test_run()
@@ -69,6 +84,16 @@ class TestGetTextLiteral(NewFile):
assert subject.get_text_literal(obj) == item
class TestGetTextProduct(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
wall = ifc.createIfcWall()
label = ifc.createIfcAnnotation()
ifcopenshell.api.run("drawing.assign_product", ifc, relating_product=wall, related_object=label)
assert subject.get_text_product(label) == wall
class TestImportTextAttributes(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
@@ -88,6 +113,30 @@ class TestImportTextAttributes(NewFile):
assert props.attributes.get("BoxAlignment").string_value == "BoxAlignment"
class TestImportTextProduct(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
wall = ifc.createIfcWall()
label = ifc.createIfcAnnotation()
ifcopenshell.api.run("drawing.assign_product", ifc, relating_product=wall, related_object=label)
wall_obj = bpy.data.objects.new("Object", None)
label_obj = bpy.data.objects.new("Object", None)
tool.Ifc.link(wall, wall_obj)
tool.Ifc.link(label, label_obj)
subject.import_text_product(label_obj)
assert label_obj.BIMTextProperties.relating_product == wall_obj
def test_doing_nothing_if_no_product_to_import(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
label = ifc.createIfcAnnotation()
label_obj = bpy.data.objects.new("Object", None)
tool.Ifc.link(label, label_obj)
subject.import_text_product(label_obj)
assert label_obj.BIMTextProperties.relating_product is None
class TestUpdateTextValue(NewFile):
def test_run(self):
TestGetTextLiteral().test_run()