From e68f25bcfbceb3983d22cc7d2f20a7c8f2ba3650 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 26 Oct 2020 14:59:18 +1100 Subject: [PATCH] ResetAbsoluteCoordinates recipe now attempts to avoid changing object placement coordinates, instead focusing on geometry coordinates. This prevents a double up when combining with the OffsetObjectPlacement recipe when doing tricky patching. --- src/ifcpatch/recipes/ResetAbsoluteCoordinates.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ifcpatch/recipes/ResetAbsoluteCoordinates.py b/src/ifcpatch/recipes/ResetAbsoluteCoordinates.py index 4cb29b7612..83edff10a6 100644 --- a/src/ifcpatch/recipes/ResetAbsoluteCoordinates.py +++ b/src/ifcpatch/recipes/ResetAbsoluteCoordinates.py @@ -6,6 +6,10 @@ class Patcher: self.args = args def patch(self): + placement_coord_ids = set() + for placement in self.file.by_type('IfcObjectPlacement'): + [placement_coord_ids.add(e.id()) for e in self.file.traverse(placement) if e.is_a('IfcCartesianPoint')] + # Arbitrary threshold based on experience self.threshold = 1000000 if self.args and len(self.args) == 1: @@ -44,6 +48,8 @@ class Patcher: for point in self.file.by_type('IfcCartesianPoint'): if len(point.Coordinates) == 2 or not self.is_point_far_away(point): continue + if point.id() in placement_coord_ids: + continue if not offset_point: offset_point = (-point.Coordinates[0], -point.Coordinates[1], -point.Coordinates[2]) self.logger.info(f'Resetting absolute coordinates by {point}')