Fix #6640. Fix invalid association of annotations to grids.

There was already some half written code with this intent it seems, so I
just finished it up.
This commit is contained in:
Dion Moult
2025-05-26 13:49:06 +10:00
parent d6cc1ff9e9
commit 810e8df6fe
5 changed files with 76 additions and 36 deletions
@@ -38,6 +38,17 @@ class TestAssignProduct(test.bootstrap.IFC4):
assert len(wall.ReferencedBy) == 1
assert wall.ReferencedBy[0].RelatedObjects == (label,)
def test_assigning_a_grid_axis(self):
axis = self.file.createIfcGridAxis(AxisTag="A")
grid = self.file.createIfcGrid(UAxes=[axis])
line = self.file.createIfcAnnotation()
ifcopenshell.api.drawing.assign_product(self.file, relating_product=axis, related_object=line)
assert grid.ReferencedBy[0].RelatedObjects == (line,)
assert grid.ReferencedBy[0].Name == "A"
assert len(self.file.by_type("IfcRelAssignsToProduct")) == 1
ifcopenshell.api.drawing.assign_product(self.file, relating_product=axis, related_object=line)
assert len(self.file.by_type("IfcRelAssignsToProduct")) == 1
class TestAssignProductIFC2X3(test.bootstrap.IFC2X3, TestAssignProduct):
pass
@@ -28,6 +28,14 @@ class TestUnassignProduct(test.bootstrap.IFC4):
ifcopenshell.api.drawing.unassign_product(self.file, relating_product=wall, related_object=label)
assert len(self.file.by_type("IfcRelAssignsToProduct")) == 0
def test_unassigning_a_grid_axis(self):
axis = self.file.createIfcGridAxis(AxisTag="A")
grid = self.file.createIfcGrid(UAxes=[axis])
line = self.file.createIfcAnnotation()
ifcopenshell.api.drawing.assign_product(self.file, relating_product=axis, related_object=line)
ifcopenshell.api.drawing.unassign_product(self.file, relating_product=axis, related_object=line)
assert len(self.file.by_type("IfcRelAssignsToProduct")) == 0
class TestUnassignProductIFC2X3(test.bootstrap.IFC2X3, TestUnassignProduct):
pass