mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-30 08:33:10 +00:00
Fix #1931. Fix bug where duplicated type products should not share material associations.
This commit is contained in:
@@ -39,6 +39,10 @@ class Usecase:
|
|||||||
inverse = ifcopenshell.util.element.copy(self.file, inverse)
|
inverse = ifcopenshell.util.element.copy(self.file, inverse)
|
||||||
inverse.RelatingMaterial = ifcopenshell.util.element.copy(self.file, inverse.RelatingMaterial)
|
inverse.RelatingMaterial = ifcopenshell.util.element.copy(self.file, inverse.RelatingMaterial)
|
||||||
inverse.RelatedObjects = [to_element]
|
inverse.RelatedObjects = [to_element]
|
||||||
|
elif inverse.is_a("IfcRelAssociatesMaterial") and from_element.is_a("IfcTypeProduct"):
|
||||||
|
inverse = ifcopenshell.util.element.copy(self.file, inverse)
|
||||||
|
inverse.RelatingMaterial = ifcopenshell.util.element.copy(self.file, inverse.RelatingMaterial)
|
||||||
|
inverse.RelatedObjects = [to_element]
|
||||||
else:
|
else:
|
||||||
for i, value in enumerate(inverse):
|
for i, value in enumerate(inverse):
|
||||||
if value == from_element:
|
if value == from_element:
|
||||||
|
|||||||
@@ -117,6 +117,14 @@ class TestCopyClass(test.bootstrap.IFC4):
|
|||||||
assert new.HasAssociations[0].RelatingMaterial != element.HasAssociations[0].RelatingMaterial
|
assert new.HasAssociations[0].RelatingMaterial != element.HasAssociations[0].RelatingMaterial
|
||||||
assert new.HasAssociations[0].RelatingMaterial.is_a("IfcMaterialLayerSetUsage")
|
assert new.HasAssociations[0].RelatingMaterial.is_a("IfcMaterialLayerSetUsage")
|
||||||
|
|
||||||
|
def test_copying_material_sets_for_type_elements_only(self):
|
||||||
|
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||||
|
material = self.file.createIfcMaterialLayerSet()
|
||||||
|
self.file.createIfcRelAssociatesMaterial(RelatedObjects=[element], RelatingMaterial=material)
|
||||||
|
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||||
|
assert new.HasAssociations[0].RelatingMaterial != element.HasAssociations[0].RelatingMaterial
|
||||||
|
assert new.HasAssociations[0].RelatingMaterial.is_a("IfcMaterialLayerSet")
|
||||||
|
|
||||||
def test_copying_a_type_and_purging_type_relationships(self):
|
def test_copying_a_type_and_purging_type_relationships(self):
|
||||||
type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||||
|
|||||||
Reference in New Issue
Block a user