From e0ed65eeb1e2edc777ca9b87703cc5272f7026ef Mon Sep 17 00:00:00 2001 From: Pekka Roivainen Date: Mon, 8 May 2017 19:18:22 +0300 Subject: [PATCH] Some input field validating --- src/Mod/Path/PathScripts/PathDrilling.py | 57 ++++++++++++++---------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathDrilling.py b/src/Mod/Path/PathScripts/PathDrilling.py index 3f23d3a6f67f..e4508ecd2de6 100644 --- a/src/Mod/Path/PathScripts/PathDrilling.py +++ b/src/Mod/Path/PathScripts/PathDrilling.py @@ -401,30 +401,39 @@ def reject(self): def getFields(self): PathLog.track() if self.obj: - if hasattr(self.obj, "StartDepth"): - self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value - if hasattr(self.obj, "FinalDepth"): - self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value - if hasattr(self.obj, "PeckDepth"): - self.obj.PeckDepth = FreeCAD.Units.Quantity(self.form.peckDepth.text()).Value - if hasattr(self.obj, "SafeHeight"): - self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value - if hasattr(self.obj, "ClearanceHeight"): - self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value - if hasattr(self.obj, "RetractHeight"): - self.obj.RetractHeight = FreeCAD.Units.Quantity(self.form.retractHeight.text()).Value - if hasattr(self.obj, "DwellTime"): - self.obj.DwellTime = FreeCAD.Units.Quantity(self.form.dwellTime.text()).Value - - if hasattr(self.obj, "DwellEnabled"): - self.obj.DwellEnabled = self.form.dwellEnabled.isChecked() - if hasattr(self.obj, "PeckEnabled"): - self.obj.PeckEnabled = self.form.peckEnabled.isChecked() - - if hasattr(self.obj, "ToolController"): - PathLog.debug("name: {}".format(self.form.uiToolController.currentText())) - tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) - self.obj.ToolController = tc + try: + if hasattr(self.obj, "StartDepth"): + self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value + if hasattr(self.obj, "FinalDepth"): + self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value + if hasattr(self.obj, "PeckDepth"): + if FreeCAD.Units.Quantity(self.form.peckDepth.text()).Value >= 0: + self.obj.PeckDepth = FreeCAD.Units.Quantity(self.form.peckDepth.text()).Value + else: + self.form.peckDepth.setText("0.00") + if hasattr(self.obj, "SafeHeight"): + self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value + if hasattr(self.obj, "ClearanceHeight"): + self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value + if hasattr(self.obj, "RetractHeight"): + self.obj.RetractHeight = FreeCAD.Units.Quantity(self.form.retractHeight.text()).Value + if hasattr(self.obj, "DwellTime"): + if FreeCAD.Units.Quantity(self.form.dwellTime.text()).Value >= 0: + self.obj.DwellTime = FreeCAD.Units.Quantity(self.form.dwellTime.text()).Value + else: + self.form.dwellTime.setText("0.00") + + if hasattr(self.obj, "DwellEnabled"): + self.obj.DwellEnabled = self.form.dwellEnabled.isChecked() + if hasattr(self.obj, "PeckEnabled"): + self.obj.PeckEnabled = self.form.peckEnabled.isChecked() + + if hasattr(self.obj, "ToolController"): + PathLog.debug("name: {}".format(self.form.uiToolController.currentText())) + tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) + self.obj.ToolController = tc + except ValueError: + self.setFields() self.obj.Proxy.execute(self.obj) def updateFeatureList(self):