From c470023719907c373782b923630834ea5a0f0e8a Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Fri, 28 Jan 2022 04:03:19 +0200 Subject: [PATCH] - fixed an error in Drilling Plugin when selecting only a few tools and not all for drilling - fixed an error when building the UI for a CNCJob object created from drilling an Excellon object with a limited selection of tools --- CHANGELOG.md | 2 ++ appObjects/FlatCAMCNCJob.py | 10 +++++++--- appPlugins/ToolDrilling.py | 6 ++++-- app_Main.py | 6 +++--- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a80268b..9f550735 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ CHANGELOG for FlatCAM beta - in Tcl command `geocutout` fixed an error due of a no longer used parameter - in camlib.CNCjob.gcode_parse() fixed an assumption that a certain object is present: tool_data["tools_drill_toolchange"] +- fixed an error in Drilling Plugin when selecting only a few tools and not all for drilling +- fixed an error when building the UI for a CNCJob object created from drilling an Excellon object with a limited selection of tools 27.01.2022 diff --git a/appObjects/FlatCAMCNCJob.py b/appObjects/FlatCAMCNCJob.py index bb1523a8..440d7ce1 100644 --- a/appObjects/FlatCAMCNCJob.py +++ b/appObjects/FlatCAMCNCJob.py @@ -196,7 +196,10 @@ class CNCJobObject(FlatCAMObj, CNCjob): self.ui.cnc_tools_table.show() if self.options['type'].lower() == 'excellon': - self.build_excellon_cnc_tools() + try: + self.build_excellon_cnc_tools() + except Exception as err: + self.app.log.error("camlib.CNCJobObject.build_ui -> %s" % str(err)) self.ui.exc_cnc_tools_table.show() self.ui_connect() @@ -330,11 +333,10 @@ class CNCJobObject(FlatCAMObj, CNCjob): n = len(self.tools) self.ui.exc_cnc_tools_table.setRowCount(n) - row_no = 1 + row_no = 0 for t_id, dia_value in self.tools.items(): tooldia = self.tools[t_id]['tooldia'] - row_no = t_id - 1 try: offset_val = self.app.dec_format(float(dia_value['offset']), self.decimals) + self.z_cut except KeyError: @@ -368,6 +370,8 @@ class CNCJobObject(FlatCAMObj, CNCjob): self.ui.exc_cnc_tools_table.setItem(row_no, 5, cutz_item) self.ui.exc_cnc_tools_table.setCellWidget(row_no, 6, plot_item) + row_no += 1 + for row in range(row_no): self.ui.exc_cnc_tools_table.item(row, 0).setFlags( self.ui.exc_cnc_tools_table.item(row, 0).flags() ^ QtCore.Qt.ItemFlag.ItemIsSelectable) diff --git a/appPlugins/ToolDrilling.py b/appPlugins/ToolDrilling.py index c9daee22..93a7586f 100644 --- a/appPlugins/ToolDrilling.py +++ b/appPlugins/ToolDrilling.py @@ -2139,8 +2139,10 @@ class ToolDrilling(AppTool, Excellon): # first drill point # I can read the toolchange x,y point from any tool since it is the same for all, so I read it - # from the first tool - job_obj.xy_toolchange = job_obj.tools[1]['data']["tools_drill_toolchangexy"] + # from the first tool that is available + + first_tool_available = sel_tools[0] + job_obj.xy_toolchange = job_obj.tools[first_tool_available]['data']["tools_drill_toolchangexy"] x_tc, y_tc = [0, 0] try: diff --git a/app_Main.py b/app_Main.py index 28c801f2..69b2a6ed 100644 --- a/app_Main.py +++ b/app_Main.py @@ -2277,7 +2277,7 @@ class App(QtCore.QObject): self.ui.popmenu_new_geo.triggered.connect(lambda: self.app_obj.new_geometry_object()) self.ui.popmenu_new_grb.triggered.connect(lambda: self.app_obj.new_gerber_object()) self.ui.popmenu_new_exc.triggered.connect(lambda: self.app_obj.new_excellon_object()) - self.ui.popmenu_new_prj.triggered.connect(lambda: self.f_handlers.on_file_new_project()) + self.ui.popmenu_new_prj.triggered.connect(lambda: self.f_handlers.on_file_new_project(silenced=True)) # View self.ui.zoomfit.triggered.connect(self.on_zoom_fit) @@ -10146,9 +10146,9 @@ class MenuFileHandlers(QtCore.QObject): elif response == bt_cancel: return elif response == bt_no: - self.on_file_new_project(use_thread=True) + self.on_file_new_project(use_thread=True, silenced=True) else: - self.on_file_new_project(use_thread=True) + self.on_file_new_project(use_thread=True, silenced=True) def on_file_new_project(self, cli=None, reset_tcl=True, use_thread=None, silenced=None): """