mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Fix issue editing object placement that shares it's axis placement with other placements
If multiple object placements were reusing the same IfcAxis2Placement then editing one of them would remove IfcAxis2Placement ignoring it's inverse references making all other object placements invalid.
This commit is contained in:
@@ -56,7 +56,7 @@ class Usecase:
|
||||
if self.file.get_total_inverses(old_placement) == 1:
|
||||
self.settings["product"].ObjectPlacement = None
|
||||
old_placement.PlacementRelTo = None
|
||||
ifcopenshell.util.element.remove_deep(self.file, old_placement)
|
||||
ifcopenshell.util.element.remove_deep2(self.file, old_placement)
|
||||
|
||||
new_placement.PlacementRelTo = placement_rel_to
|
||||
self.settings["product"].ObjectPlacement = new_placement
|
||||
|
||||
@@ -134,6 +134,39 @@ class TestEditObjectPlacement(test.bootstrap.IFC4):
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix2)
|
||||
assert element.ObjectPlacement != element2.ObjectPlacement
|
||||
|
||||
def test_changing_an_object_placement_partially_used_by_other_products(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
matrix1 = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 1.0),
|
||||
(0.0, 1.0, 0.0, 2.0),
|
||||
(0.0, 0.0, 1.0, 3.0),
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
matrix2 = numpy.array(
|
||||
(
|
||||
(1.0, 0.0, 0.0, 4.0),
|
||||
(0.0, 1.0, 0.0, 5.0),
|
||||
(0.0, 0.0, 1.0, 6.0),
|
||||
(0.0, 0.0, 0.0, 1.0),
|
||||
)
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix1.copy(), is_si=False
|
||||
)
|
||||
element2.ObjectPlacement = self.file.createIfcLocalPlacement(
|
||||
RelativePlacement=element.ObjectPlacement.RelativePlacement
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"geometry.edit_object_placement", self.file, product=element, matrix=matrix2.copy(), is_si=False
|
||||
)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement), matrix2)
|
||||
assert numpy.array_equal(ifcopenshell.util.placement.get_local_placement(element2.ObjectPlacement), matrix1)
|
||||
|
||||
def test_changing_an_object_placement_shared_by_its_parent(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file)
|
||||
|
||||
Reference in New Issue
Block a user