Fix bug where appending a product from a library which had relationships to types caused a bunch of types to be pulled in unintentionally

This commit is contained in:
Dion Moult
2023-03-24 20:53:55 +11:00
parent f3f90e0ad5
commit 346071185f
2 changed files with 15 additions and 0 deletions
@@ -302,6 +302,19 @@ class TestAppendAsset(test.bootstrap.IFC4):
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
assert ifcopenshell.util.element.get_material(self.file.by_type("IfcWall")[0]).Name == "Material"
def test_append_a_product_where_its_inverse_material_relationship_refers_to_product_types_not_in_scope(self):
library = ifcopenshell.api.run("project.create_file")
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
element_type = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
element_type2 = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWallType")
ifcopenshell.api.run("type.assign_type", library, related_object=element, relating_type=element_type)
material = ifcopenshell.api.run("material.add_material", library, name="Material")
ifcopenshell.api.run("material.assign_material", library, product=element, material=material)
ifcopenshell.api.run("material.assign_material", library, product=element_type, material=material)
ifcopenshell.api.run("material.assign_material", library, product=element_type2, material=material)
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
assert [e.GlobalId for e in self.file.by_type("IfcWallType")] == [element_type.GlobalId]
def test_append_a_product_with_its_styles(self):
library = ifcopenshell.api.run("project.create_file")
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")