Fix #2837. Shared subelements mistakenly caused the subelement append loop to break early. The solution is to traverse one level at a time.

This commit is contained in:
Dion Moult
2023-03-24 17:35:10 +11:00
parent 808cb6ec14
commit 00fc71dcbe
2 changed files with 17 additions and 6 deletions
@@ -116,6 +116,16 @@ class TestAppendAsset(test.bootstrap.IFC4):
def test_append_a_type_product_with_its_styles(self):
library = ifcopenshell.api.run("project.create_file")
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
history = library.createIfcOwnerHistory()
element.OwnerHistory = history
material = ifcopenshell.api.run("material.add_material", library, name="Material")
rel = ifcopenshell.api.run("material.assign_material", library, product=element, material=material)
# We share a history. This ensures that we continue to check all
# whitelisted inverses even though one of the subelements (i.e. this
# shared history) is already processed. See bug #2837.
rel.OwnerHistory = history
item = library.createIfcBoundingBox()
library.createIfcStyledItem(Item=item)
mapped_rep = library.createIfcShapeRepresentation(Items=[item])