From 5f739d1baf0a26dc4ff4fce085ea7b5a2c452fd4 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 10 Dec 2019 23:57:00 +0200 Subject: [PATCH] - if extracut_length is zero then the extracut will cut up until the first point in path no matter what the distance is --- FlatCAMApp.py | 4 +-- FlatCAMCommon.py | 12 ++++--- FlatCAMObj.py | 56 ++++++++++++++++----------------- README.md | 2 ++ camlib.py | 4 +-- flatcamGUI/ObjectUI.py | 8 +++-- flatcamGUI/PreferencesUI.py | 9 ++++-- flatcamParsers/ParseExcellon.py | 14 ++++----- tclCommands/TclCommandCncjob.py | 2 +- 9 files changed, 62 insertions(+), 49 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 439b1a39..c0f8cb48 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -591,7 +591,7 @@ class App(QtCore.QObject): "excellon_travelz": 2, "excellon_endz": 0.5, "excellon_feedrate": 300, - "excellon_spindlespeed": None, + "excellon_spindlespeed": 0, "excellon_dwell": False, "excellon_dwelltime": 1, "excellon_toolchange": False, @@ -658,7 +658,7 @@ class App(QtCore.QObject): "geometry_endz": 15.0, "geometry_feedrate": 120, "geometry_feedrate_z": 60, - "geometry_spindlespeed": None, + "geometry_spindlespeed": 0, "geometry_dwell": False, "geometry_dwelltime": 1, "geometry_ppname_g": 'default', diff --git a/FlatCAMCommon.py b/FlatCAMCommon.py index 547e4fef..ec6db2b8 100644 --- a/FlatCAMCommon.py +++ b/FlatCAMCommon.py @@ -12,7 +12,7 @@ # ########################################################## from PyQt5 import QtGui, QtCore, QtWidgets -from flatcamGUI.GUIElements import FCTable, FCEntry, FCButton, FCDoubleSpinner, FCComboBox, FCCheckBox +from flatcamGUI.GUIElements import FCTable, FCEntry, FCButton, FCDoubleSpinner, FCComboBox, FCCheckBox, FCSpinner from camlib import to_dict import sys @@ -908,8 +908,11 @@ class ToolsDB(QtWidgets.QWidget): frrapids_item.set_value(float(data['feedrate_rapid'])) widget.setCellWidget(row, 15, frrapids_item) - spindlespeed_item = QtWidgets.QTableWidgetItem(str(data['spindlespeed']) if data['spindlespeed'] else '') - widget.setItem(row, 16, spindlespeed_item) + spindlespeed_item = FCSpinner() + spindlespeed_item.set_range(0, 1000000) + spindlespeed_item.set_range(int(data['spindlespeed'])) + spindlespeed_item.setSingleStep(100) + widget.setCellWidget(row, 16, spindlespeed_item) dwell_item = FCCheckBox() dwell_item.set_value(data['dwell']) @@ -1282,8 +1285,7 @@ class ToolsDB(QtWidgets.QWidget): elif column_header_text == 'FR Rapids': default_data['feedrate_rapid'] = self.table_widget.cellWidget(row, col).get_value() elif column_header_text == 'Spindle Speed': - default_data['spindlespeed'] = float(self.table_widget.item(row, col).text()) \ - if self.table_widget.item(row, col).text() is not '' else None + default_data['spindlespeed'] = self.table_widget.cellWidget(row, col).get_value() elif column_header_text == 'Dwell': default_data['dwell'] = self.table_widget.cellWidget(row, col).get_value() elif column_header_text == 'Dwelltime': diff --git a/FlatCAMObj.py b/FlatCAMObj.py index aac9f8a0..5f85e0f7 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -2195,7 +2195,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): "toolchangexy": "0.0, 0.0", "endz": 2.0, "startz": None, - "spindlespeed": None, + "spindlespeed": 0, "dwell": True, "dwelltime": 1000, "ppname_e": 'defaults', @@ -3253,7 +3253,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): job_obj.feedrate = float(self.options["feedrate"]) job_obj.feedrate_rapid = float(self.options["feedrate_rapid"]) - job_obj.spindlespeed = float(self.options["spindlespeed"]) if self.options["spindlespeed"] else None + job_obj.spindlespeed = float(self.options["spindlespeed"]) if self.options["spindlespeed"] != 0 else None job_obj.spindledir = self.app.defaults['excellon_spindledir'] job_obj.dwell = self.options["dwell"] job_obj.dwelltime = float(self.options["dwelltime"]) @@ -3332,30 +3332,31 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): def convert_units(self, units): log.debug("FlatCAMObj.FlatCAMExcellon.convert_units()") - factor = Excellon.convert_units(self, units) + Excellon.convert_units(self, units) - self.options['drillz'] = float(self.options['drillz']) * factor - self.options['travelz'] = float(self.options['travelz']) * factor - self.options['feedrate'] = float(self.options['feedrate']) * factor - self.options['feedrate_rapid'] = float(self.options['feedrate_rapid']) * factor - self.options['toolchangez'] = float(self.options['toolchangez']) * factor - - if self.app.defaults["excellon_toolchangexy"] == '': - self.options['toolchangexy'] = "0.0, 0.0" - else: - coords_xy = [float(eval(coord)) for coord in self.app.defaults["excellon_toolchangexy"].split(",")] - if len(coords_xy) < 2: - self.app.inform.emit('[ERROR] %s' % _("The Toolchange X,Y field in Edit -> Preferences has to be " - "in the format (x, y) \n" - "but now there is only one value, not two. ")) - return 'fail' - coords_xy[0] *= factor - coords_xy[1] *= factor - self.options['toolchangexy'] = "%f, %f" % (coords_xy[0], coords_xy[1]) - - if self.options['startz'] is not None: - self.options['startz'] = float(self.options['startz']) * factor - self.options['endz'] = float(self.options['endz']) * factor + # factor = Excellon.convert_units(self, units) + # self.options['drillz'] = float(self.options['drillz']) * factor + # self.options['travelz'] = float(self.options['travelz']) * factor + # self.options['feedrate'] = float(self.options['feedrate']) * factor + # self.options['feedrate_rapid'] = float(self.options['feedrate_rapid']) * factor + # self.options['toolchangez'] = float(self.options['toolchangez']) * factor + # + # if self.app.defaults["excellon_toolchangexy"] == '': + # self.options['toolchangexy'] = "0.0, 0.0" + # else: + # coords_xy = [float(eval(coord)) for coord in self.app.defaults["excellon_toolchangexy"].split(",")] + # if len(coords_xy) < 2: + # self.app.inform.emit('[ERROR] %s' % _("The Toolchange X,Y field in Edit -> Preferences has to be " + # "in the format (x, y) \n" + # "but now there is only one value, not two. ")) + # return 'fail' + # coords_xy[0] *= factor + # coords_xy[1] *= factor + # self.options['toolchangexy'] = "%f, %f" % (coords_xy[0], coords_xy[1]) + # + # if self.options['startz'] is not None: + # self.options['startz'] = float(self.options['startz']) * factor + # self.options['endz'] = float(self.options['endz']) * factor def on_solid_cb_click(self, *args): if self.muted_ui: @@ -3517,7 +3518,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): "feedrate": 5.0, "feedrate_z": 5.0, "feedrate_rapid": 5.0, - "spindlespeed": None, + "spindlespeed": 0, "dwell": True, "dwelltime": 1000, "multidepth": False, @@ -3806,7 +3807,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): "toolchange": None, "toolchangez": None, "endz": None, - "spindlespeed": None, + "spindlespeed": 0, "toolchangexy": None, "startz": None }) @@ -5713,7 +5714,6 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): tooldia = self.ui.addtool_entry.get_value() if tooldia: tooldia *= factor - # limit the decimals to 2 for METRIC and 3 for INCH tooldia = float('%.*f' % (self.decimals, tooldia)) self.ui.addtool_entry.set_value(tooldia) diff --git a/README.md b/README.md index 6e5d96b5..cefa4748 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ CAD program, and create G-Code for Isolation routing. - fixed a cummulative error when using the Tool Offset for Excellon objects - added the display of the real depth of cut (cut z + offset_z) for CNC tools made out of an Excellon object - for OpenGL graphic mode added a fit_view() execution on canvas initialization +- fixed Excellon scaling the UI values +- replaced the SpindleSpeed entry with a FCSpinner() GUI element; if speed is set to 0 it will amount to None 9.12.2019 diff --git a/camlib.py b/camlib.py index 98b28775..0e86f66a 100644 --- a/camlib.py +++ b/camlib.py @@ -3036,7 +3036,7 @@ class CNCjob(Geometry): self.z_feedrate = float(feedrate_z) if feedrate_z is not None else None self.feedrate_rapid = float(feedrate_rapid) if feedrate_rapid else None - self.spindlespeed = int(spindlespeed) if spindlespeed else None + self.spindlespeed = int(spindlespeed) if spindlespeed != 0 else None self.spindledir = spindledir self.dwell = dwell self.dwelltime = float(dwelltime) if dwelltime else None @@ -3388,7 +3388,7 @@ class CNCjob(Geometry): self.z_feedrate = float(feedrate_z) if feedrate_z is not None else None self.feedrate_rapid = float(feedrate_rapid) if feedrate_rapid else None - self.spindlespeed = int(spindlespeed) if spindlespeed else None + self.spindlespeed = int(spindlespeed) if spindlespeed != 0 else None self.spindledir = spindledir self.dwell = dwell self.dwelltime = float(dwelltime) if dwelltime else None diff --git a/flatcamGUI/ObjectUI.py b/flatcamGUI/ObjectUI.py index ad8ca9cf..a7bd2875 100644 --- a/flatcamGUI/ObjectUI.py +++ b/flatcamGUI/ObjectUI.py @@ -932,7 +932,9 @@ class ExcellonObjectUI(ObjectUI): "in RPM (optional)") ) grid1.addWidget(spdlabel, 8, 0) - self.spindlespeed_entry = IntEntry(allow_empty=True) + self.spindlespeed_entry = FCSpinner() + self.spindlespeed_entry.set_range(0, 1000000) + self.spindlespeed_entry.setSingleStep(100) grid1.addWidget(self.spindlespeed_entry, 8, 1) # Dwell @@ -1571,7 +1573,9 @@ class GeometryObjectUI(ObjectUI): "this value is the power of laser." ) ) - self.cncspindlespeed_entry = IntEntry(allow_empty=True) + self.cncspindlespeed_entry = FCSpinner() + self.cncspindlespeed_entry.set_range(0, 1000000) + self.cncspindlespeed_entry.setSingleStep(100) self.grid3.addWidget(spdlabel, 14, 0) self.grid3.addWidget(self.cncspindlespeed_entry, 14, 1) diff --git a/flatcamGUI/PreferencesUI.py b/flatcamGUI/PreferencesUI.py index 7eb6c759..00d75118 100644 --- a/flatcamGUI/PreferencesUI.py +++ b/flatcamGUI/PreferencesUI.py @@ -2430,7 +2430,9 @@ class ExcellonOptPrefGroupUI(OptionsGroupUI): "in RPM (optional)") ) grid2.addWidget(spdlabel, 6, 0) - self.spindlespeed_entry = IntEntry(allow_empty=True) + self.spindlespeed_entry = FCSpinner() + self.spindlespeed_entry.set_range(0, 1000000) + self.spindlespeed_entry.setSingleStep(100) grid2.addWidget(self.spindlespeed_entry, 6, 1) # Dwell @@ -3341,7 +3343,10 @@ class GeometryOptPrefGroupUI(OptionsGroupUI): ) ) grid1.addWidget(spdlabel, 9, 0) - self.cncspindlespeed_entry = IntEntry(allow_empty=True) + self.cncspindlespeed_entry = FCSpinner() + self.cncspindlespeed_entry.set_range(0, 1000000) + self.cncspindlespeed_entry.setSingleStep(100) + grid1.addWidget(self.cncspindlespeed_entry, 9, 1) # Dwell diff --git a/flatcamParsers/ParseExcellon.py b/flatcamParsers/ParseExcellon.py index cf2c6293..7bccf8f0 100644 --- a/flatcamParsers/ParseExcellon.py +++ b/flatcamParsers/ParseExcellon.py @@ -94,11 +94,11 @@ class Excellon(Geometry): Geometry.__init__(self, geo_steps_per_circle=int(geo_steps_per_circle)) # dictionary to store tools, see above for description - self.tools = {} + self.tools = dict() # list to store the drills, see above for description - self.drills = [] + self.drills = list() # self.slots (list) to store the slots; each is a dictionary - self.slots = [] + self.slots = list() self.source_file = '' @@ -109,8 +109,8 @@ class Excellon(Geometry): self.match_routing_start = None self.match_routing_stop = None - self.num_tools = [] # List for keeping the tools sorted - self.index_per_tool = {} # Dictionary to store the indexed points for each tool + self.num_tools = list() # List for keeping the tools sorted + self.index_per_tool = dict() # Dictionary to store the indexed points for each tool # ## IN|MM -> Units are inherited from Geometry self.units = self.app.defaults['units'] @@ -118,8 +118,8 @@ class Excellon(Geometry): # Trailing "T" or leading "L" (default) # self.zeros = "T" self.zeros = zeros or self.defaults["zeros"] - self.zeros_found = self.zeros - self.units_found = self.units + self.zeros_found = deepcopy(self.zeros) + self.units_found = deepcopy(self.units) # this will serve as a default if the Excellon file has no info regarding of tool diameters (this info may be # in another file like for PCB WIzard ECAD software diff --git a/tclCommands/TclCommandCncjob.py b/tclCommands/TclCommandCncjob.py index 0d5fd686..3b08e8f6 100644 --- a/tclCommands/TclCommandCncjob.py +++ b/tclCommands/TclCommandCncjob.py @@ -147,7 +147,7 @@ class TclCommandCncjob(TclCommandSignaled): self.app.defaults["geometry_startz"] args["endz"] = args["endz"] if "endz" in args and args["endz"] else obj.options["endz"] - args["spindlespeed"] = args["spindlespeed"] if "spindlespeed" in args and args["spindlespeed"] else None + args["spindlespeed"] = args["spindlespeed"] if "spindlespeed" in args and args["spindlespeed"] != 0 else None args["dwell"] = bool(args["dwell"]) if "dwell" in args else obj.options["dwell"] args["dwelltime"] = args["dwelltime"] if "dwelltime" in args and args["dwelltime"] else obj.options["dwelltime"]