From 205da63d8e39718cdf6473c1a4dd11ba3afdd111 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 19 Mar 2024 16:49:18 +0500 Subject: [PATCH] util.selector.set_element_value ignore values within tolerance #4439 --- src/ifcopenshell-python/ifcopenshell/util/selector.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py index bed118ac70..7dd3485a67 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/selector.py +++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py @@ -367,7 +367,15 @@ def set_element_value( return matrix = ifcopenshell.util.placement.get_local_placement(element.ObjectPlacement) coord_i = "xyz".index(key) - matrix[coord_i][3] = float(value) if value else 0.0 + + # check if value is within tolerance to avoid api calls + prev_value = matrix[coord_i][3] + new_value = float(value) if value else 0.0 + TOLERANCE = 1.0e-5 + if new_value + TOLERANCE > prev_value > new_value - TOLERANCE: + return + + matrix[coord_i][3] = new_value ifcopenshell.api.run( "geometry.edit_object_placement", ifc_file, product=element, matrix=matrix, is_si=False )