Port locations now sync relative to their parent even when not actively displayed in the viewport

This commit is contained in:
Dion Moult
2022-05-05 18:00:42 +10:00
parent 3213af2f48
commit 53c050c6ed
13 changed files with 93 additions and 27 deletions
@@ -103,6 +103,10 @@ class Usecase:
for referenced_placement in placement.ReferencedByPlacements:
matrix = ifcopenshell.util.placement.get_local_placement(referenced_placement)
for obj in referenced_placement.PlacesObject:
# Although a port is technically a nested child, it is generally
# more intuitive that the ports always move with the parent.
if obj.is_a("IfcDistributionPort"):
continue
results.append({"product": obj, "matrix": matrix, "is_si": False, "should_transform_children": False})
results.extend(self.get_children_settings(referenced_placement))
return results
@@ -49,13 +49,20 @@ class Usecase:
ports = [e for e in inverse.RelatedObjects if e.is_a("IfcDistributionPort")]
if ports:
new_ports = [ifcopenshell.api.run("root.copy_class", self.file, product=p) for p in ports]
[
ifcopenshell.api.run("system.unassign_port", self.file, element=from_element, port=p)
for p in new_ports
]
inverse = ifcopenshell.util.element.copy(self.file, inverse)
inverse.RelatingObject = to_element
inverse.RelatedObjects = new_ports
for port in new_ports:
ifcopenshell.api.run("system.unassign_port", self.file, element=from_element, port=port)
matrix = ifcopenshell.util.placement.get_local_placement(port.ObjectPlacement)
ifcopenshell.api.run(
"geometry.edit_object_placement",
self.file,
product=port,
matrix=matrix,
is_si=False,
should_transform_children=False,
)
elif inverse.is_a("IfcRelAggregates") and inverse.RelatingObject == from_element:
continue
elif inverse.is_a("IfcRelContainedInSpatialStructure") and inverse.RelatingStructure == from_element: