From 2ea2ed0cb0de0015bfa779221f2839b27fe7b8d2 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 5 Feb 2019 22:32:48 +0200 Subject: [PATCH] - fixed the units calculators crash FlatCAM when using comma as decimal separator --- FlatCAMApp.py | 4 ++-- README.md | 4 ++++ flatcamTools/ToolCalculators.py | 24 ++++++++++++++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 84e13f14..d4f8f99b 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -92,8 +92,8 @@ class App(QtCore.QObject): log.addHandler(handler) # Version - version = 8.906 - version_date = "2019/02/5" + version = 8.907 + version_date = "2019/02/6" beta = True # current date now diff --git a/README.md b/README.md index d5d2dc33..7b09ea0a 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing. ================================================= +6.02.2019 + +- fixed the units calculators crash FlatCAM when using comma as decimal separator + 5.02.3019 - added a text in the Selected Tab which is showed whenever the Selected Tab is selected but without having an object selected to display it's properties diff --git a/flatcamTools/ToolCalculators.py b/flatcamTools/ToolCalculators.py index 80996770..cd42881e 100644 --- a/flatcamTools/ToolCalculators.py +++ b/flatcamTools/ToolCalculators.py @@ -293,10 +293,30 @@ class ToolCalculator(FlatCAMTool): self.effectiveToolDia_entry.set_value("%.4f" % tool_diameter) def on_calculate_inch_units(self): - self.inch_entry.set_value('%.6f' % (float(self.mm_entry.get_value()) / 25.4)) + try: + mm_val = float(self.mm_entry.get_value()) + except ValueError: + # try to convert comma to decimal point. if it's still not working error message and return + try: + mm_val = float(self.mm_entry.get_value().replace(',', '.')) + except ValueError: + self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered, " + "use a number.") + return + self.inch_entry.set_value('%.6f' % (mm_val / 25.4)) def on_calculate_mm_units(self): - self.mm_entry.set_value('%.6f' % (float(self.inch_entry.get_value()) * 25.4)) + try: + inch_val = float(self.inch_entry.get_value()) + except ValueError: + # try to convert comma to decimal point. if it's still not working error message and return + try: + inch_val = float(self.inch_entry.get_value().replace(',', '.')) + except ValueError: + self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered, " + "use a number.") + return + self.mm_entry.set_value('%.6f' % (inch_val * 25.4)) def on_calculate_eplate(self):