mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 02:10:03 +00:00
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:
@@ -258,6 +258,8 @@ class Usecase:
|
|||||||
return False
|
return False
|
||||||
elif element.is_a(self.target_class):
|
elif element.is_a(self.target_class):
|
||||||
return True
|
return True
|
||||||
|
elif self.target_class == "IfcProduct" and element.is_a("IfcTypeProduct"):
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def reuse_existing_contexts(self):
|
def reuse_existing_contexts(self):
|
||||||
|
|||||||
@@ -302,6 +302,19 @@ class TestAppendAsset(test.bootstrap.IFC4):
|
|||||||
ifcopenshell.api.run("project.append_asset", self.file, library=library, element=element)
|
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"
|
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):
|
def test_append_a_product_with_its_styles(self):
|
||||||
library = ifcopenshell.api.run("project.create_file")
|
library = ifcopenshell.api.run("project.create_file")
|
||||||
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", library, ifc_class="IfcWall")
|
||||||
|
|||||||
Reference in New Issue
Block a user