From aa76499a53d3fe3139f312cc85430b689fea853d Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Wed, 26 May 2021 23:09:36 -0500 Subject: [PATCH] Path: Fix bug with inaccurate Task Panel values upon new op creation Path: Fix bug with inaccurate Task Panel values upon new op creation --- src/Mod/Path/PathScripts/PathGui.py | 14 +++++++++++++- src/Mod/Path/PathScripts/PathOpGui.py | 11 +++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Mod/Path/PathScripts/PathGui.py b/src/Mod/Path/PathScripts/PathGui.py index 3280a93d02..1d0d58f358 100644 --- a/src/Mod/Path/PathScripts/PathGui.py +++ b/src/Mod/Path/PathScripts/PathGui.py @@ -100,6 +100,7 @@ class QuantitySpinBox: self.widget = widget self.onBeforeChange = onBeforeChange self.prop = None + self.obj = obj self.attachTo(obj, prop) def attachTo(self, obj, prop = None): @@ -139,9 +140,14 @@ class QuantitySpinBox: If no value is provided the value of the bound property is used. quantity can be of type Quantity or Float.''' PathLog.track(self.prop, self.valid) + if self.valid: + expr = self._hasExpression() if quantity is None: - quantity = PathUtil.getProperty(self.obj, self.prop) + if expr: + quantity = FreeCAD.Units.Quantity(self.obj.evalExpression(expr)) + else: + quantity = PathUtil.getProperty(self.obj, self.prop) value = quantity.Value if hasattr(quantity, 'Value') else quantity self.widget.setProperty('rawValue', value) @@ -151,3 +157,9 @@ class QuantitySpinBox: if self.valid: return updateInputField(self.obj, self.prop, self.widget, self.onBeforeChange) return None + + def _hasExpression(self): + for (prop, exp) in self.obj.ExpressionEngine: + if prop == self.prop: + return exp + return None diff --git a/src/Mod/Path/PathScripts/PathOpGui.py b/src/Mod/Path/PathScripts/PathOpGui.py index 9d9ef3d4dd..33de983c24 100644 --- a/src/Mod/Path/PathScripts/PathOpGui.py +++ b/src/Mod/Path/PathScripts/PathOpGui.py @@ -1203,7 +1203,18 @@ class TaskPanel(object): page.clearBase() page.addBaseGeometry(sel) + # Update properties based upon expressions in case expression value has changed + for (prp, expr) in self.obj.ExpressionEngine: + val = FreeCAD.Units.Quantity(self.obj.evalExpression(expr)) + value = val.Value if hasattr(val, 'Value') else val + prop = getattr(self.obj, prp) + if hasattr(prop, "Value"): + prop.Value = value + else: + prop = value + self.panelSetFields() + for page in self.featurePages: page.pageRegisterSignalHandlers()