mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Fix #2974. Type property sets are now properly copied.
This commit is contained in:
@@ -76,6 +76,7 @@ class Usecase:
|
||||
def copy_direct_attributes(self, to_element):
|
||||
self.remove_representations(to_element)
|
||||
self.copy_object_placements(to_element)
|
||||
self.copy_psets(to_element)
|
||||
|
||||
def copy_indirect_attributes(self, from_element, to_element):
|
||||
for inverse in self.file.get_inverse(from_element):
|
||||
@@ -160,3 +161,10 @@ class Usecase:
|
||||
element.ObjectPlacement.RelativePlacement = ifcopenshell.util.element.copy_deep(
|
||||
self.file, element.ObjectPlacement.RelativePlacement
|
||||
)
|
||||
|
||||
def copy_psets(self, element):
|
||||
if not element.is_a("IfcTypeObject") or not element.HasPropertySets:
|
||||
return
|
||||
element.HasPropertySets = [
|
||||
ifcopenshell.util.element.copy_deep(self.file, pset) for pset in element.HasPropertySets
|
||||
]
|
||||
|
||||
@@ -57,6 +57,20 @@ class TestCopyClass(test.bootstrap.IFC4):
|
||||
assert pset.HasProperties[0].Name == new_pset.HasProperties[0].Name
|
||||
assert pset.HasProperties[0].NominalValue.wrappedValue == new_pset.HasProperties[0].NominalValue.wrappedValue
|
||||
|
||||
def test_copying_type_psets_so_changing_properties_of_the_new_type_does_not_affect_the_old(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foobar")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"foo": "bar"})
|
||||
new = ifcopenshell.api.run("root.copy_class", self.file, product=element)
|
||||
pset = element.HasPropertySets[0]
|
||||
new_pset = new.HasPropertySets[0]
|
||||
assert element.HasPropertySets[0] != new.HasPropertySets[0]
|
||||
assert pset != new_pset
|
||||
assert pset.Name == new_pset.Name
|
||||
assert pset.HasProperties[0] != new_pset.HasProperties[0]
|
||||
assert pset.HasProperties[0].Name == new_pset.HasProperties[0].Name
|
||||
assert pset.HasProperties[0].NominalValue.wrappedValue == new_pset.HasProperties[0].NominalValue.wrappedValue
|
||||
|
||||
def test_copying_a_container_only_and_not_its_contents(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcBuilding")
|
||||
subelement = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
|
||||
Reference in New Issue
Block a user