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
@@ -0,0 +1,20 @@
import test.bootstrap
import ifcopenshell.api
class TestAssignProduct(test.bootstrap.IFC4):
def test_assigning_a_product(self):
wall = self.file.createIfcWall()
label = self.file.createIfcAnnotation()
label2 = self.file.createIfcAnnotation()
ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=wall, related_object=label)
assert wall.ReferencedBy[0].RelatedObjects == (label,)
ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=wall, related_object=label2)
assert wall.ReferencedBy[0].RelatedObjects == (label, label2)
def test_not_assigning_twice(self):
wall = self.file.createIfcWall()
label = self.file.createIfcAnnotation()
ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=wall, related_object=label)
ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=wall, related_object=label)
assert wall.ReferencedBy[0].RelatedObjects == (label,)
@@ -0,0 +1,11 @@
import test.bootstrap
import ifcopenshell.api
class TestUnassignProduct(test.bootstrap.IFC4):
def test_unassigning_a_product(self):
wall = self.file.createIfcWall()
label = self.file.createIfcAnnotation()
ifcopenshell.api.run("drawing.assign_product", self.file, relating_product=wall, related_object=label)
ifcopenshell.api.run("drawing.unassign_product", self.file, relating_product=wall, related_object=label)
assert len(self.file.by_type("IfcRelAssignsToProduct")) == 0