From f02b6f43cab56f4963f31d3f0ec76bb8d6d53ccf Mon Sep 17 00:00:00 2001 From: Billy Huddleston Date: Thu, 2 Oct 2025 18:48:03 -0400 Subject: [PATCH] CAM: Fix Topo recomputation by only updating when values change in Toolbits - Use PathUtil.setProperty instead of direct setattr for schema properties to ensure proper FreeCAD notifications. - Only update custom shape properties if the value has changed, reducing unnecessary recomputation. - For SpindleDirection and Material, only update the property if the new value differs from the current value, and use PathUtil.setProperty for consistency. - This prevents overwriting existing values with defaults and avoids triggering unwanted recomputation. --- src/Mod/CAM/Path/Tool/toolbit/models/base.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Mod/CAM/Path/Tool/toolbit/models/base.py b/src/Mod/CAM/Path/Tool/toolbit/models/base.py index a3e4ce9374..bee28646e6 100644 --- a/src/Mod/CAM/Path/Tool/toolbit/models/base.py +++ b/src/Mod/CAM/Path/Tool/toolbit/models/base.py @@ -683,7 +683,7 @@ class ToolBit(Asset, ABC): # Conditional to avoid unnecessary migration warning when called # from onDocumentRestored. if value is not None and getattr(self.obj, name) != value: - setattr(self.obj, name, value) + PathUtil.setProperty(self.obj, name, value) # 2. Add additional properties that are part of the shape, # but not part of the schema. @@ -708,7 +708,8 @@ class ToolBit(Asset, ABC): Path.Log.debug(f"Added custom shape property: {name} ({prop_type})") # Set the property value - PathUtil.setProperty(self.obj, name, value) + if value is not None and getattr(self.obj, name) != value: + PathUtil.setProperty(self.obj, name, value) self.obj.setEditorMode(name, 0) # 3. Ensure SpindleDirection property exists and is set @@ -725,8 +726,12 @@ class ToolBit(Asset, ABC): self.obj.SpindleDirection = "Forward" # Default value spindle_value = self._tool_bit_shape.get_parameters().get("SpindleDirection") - if spindle_value in ("Forward", "Reverse", "None"): - self.obj.SpindleDirection = spindle_value + if ( + spindle_value in ("Forward", "Reverse", "None") + and self.obj.SpindleDirection != spindle_value + ): + # self.obj.SpindleDirection = spindle_value + PathUtil.setProperty(self.obj, "SpindleDirection", spindle_value) # 4. Ensure Material property exists and is set if not hasattr(self.obj, "Material"): @@ -740,8 +745,8 @@ class ToolBit(Asset, ABC): self.obj.Material = "HSS" # Default value material_value = self._tool_bit_shape.get_parameters().get("Material") - if material_value in ("HSS", "Carbide"): - self.obj.Material = material_value + if material_value in ("HSS", "Carbide") and self.obj.Material != material_value: + PathUtil.setProperty(self.obj, "Material", material_value) def _update_visual_representation(self): """