diff --git a/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py b/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py index edea2b586f..f825445428 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py +++ b/src/ifcopenshell-python/ifcopenshell/api/project/append_asset.py @@ -258,6 +258,8 @@ class Usecase: return False elif element.is_a(self.target_class): return True + elif self.target_class == "IfcProduct" and element.is_a("IfcTypeProduct"): + return True return False def reuse_existing_contexts(self): diff --git a/src/ifcopenshell-python/test/api/project/test_append_asset.py b/src/ifcopenshell-python/test/api/project/test_append_asset.py index 9641cefb1e..290ed90399 100644 --- a/src/ifcopenshell-python/test/api/project/test_append_asset.py +++ b/src/ifcopenshell-python/test/api/project/test_append_asset.py @@ -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")