From c2677cac262eb2412bd96431227b2ffb98595028 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Thu, 1 Apr 2021 19:34:46 +0300 Subject: [PATCH] - fixed bug in the Drilling Tool when there are tools without drill points --- CHANGELOG.md | 4 ++++ appPlugins/ToolDrilling.py | 14 +++++++++++--- app_Main.py | 11 +++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03062e62..e2b829db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta ================================================= +1.04.2021 + +- fixed bug in the Drilling Tool when there are tools without drill points + 29.03.2021 - Milling Plugin - finished the polish functionality diff --git a/appPlugins/ToolDrilling.py b/appPlugins/ToolDrilling.py index b20bcc3f..c45d7ac6 100644 --- a/appPlugins/ToolDrilling.py +++ b/appPlugins/ToolDrilling.py @@ -1828,6 +1828,7 @@ class ToolDrilling(AppTool, Excellon): points[tool_key].append(drill_pt) except KeyError: points[tool_key] = [drill_pt] + log.debug("Found %d TOOLS with drills." % len(points)) # ############################################################################################################# @@ -2081,7 +2082,8 @@ class ToolDrilling(AppTool, Excellon): if toolchange is False: tool_points = [] for tool in sel_tools: - tool_points += points[tool] + if tool in points: + tool_points += points[tool] # use the first tool in the selection as the tool that we are going to use used_tool = sel_tools[0] @@ -2117,7 +2119,9 @@ class ToolDrilling(AppTool, Excellon): # ####################### TOOLCHANGE ACTIVE ###################################################### else: for tool_id in sel_tools: - tool_points = points[tool_id] + tool_points = [] + if tool_id in points: + tool_points = points[tool_id] used_tooldia = self.excellon_tools[tool_id]['tooldia'] # those are used by the preprocessors to display data on the toolchange line @@ -2127,7 +2131,7 @@ class ToolDrilling(AppTool, Excellon): # if slots are converted to drill for this tool, update the number of drills and make slots nr zero convert_slots = self.excellon_tools[tool_id]['data']['tools_drill_drill_slots'] if convert_slots is True: - nr_drills = len(points[tool_id]) + nr_drills = len(tool_points) nr_slots = 0 job_obj.tools[used_tooldia]['nr_drills'] = nr_drills job_obj.tools[used_tooldia]['nr_slots'] = nr_slots @@ -2138,6 +2142,10 @@ class ToolDrilling(AppTool, Excellon): is_last_tool = True if tool_id == sel_tools[-1] else False is_first_tool = True if tool_id == sel_tools[0] else False + if not tool_points: + self.app.log.debug("%s" % "Tool has no drill points. Skipping.") + continue + # Generate Gcode for the current tool tool_gcode, last_pt, start_gcode = job_obj.excellon_tool_gcode_gen(tool_id, tool_points, self.excellon_tools, diff --git a/app_Main.py b/app_Main.py index 5eceb4bd..6a2fc561 100644 --- a/app_Main.py +++ b/app_Main.py @@ -6533,6 +6533,17 @@ class App(QtCore.QObject): self.ui.notebook.setCurrentWidget(self.ui.properties_tab) self.ui.notebook.removeTab(2) + # HACK: the content was removed but let's create it again + self.ui.plugin_tab = QtWidgets.QWidget() + self.ui.plugin_tab.setObjectName("plugin_tab") + self.ui.plugin_tab_layout = QtWidgets.QVBoxLayout(self.ui.plugin_tab) + self.ui.plugin_tab_layout.setContentsMargins(2, 2, 2, 2) + # self.notebook.addTab(self.plugin_tab, _("Tool")) + + self.ui.plugin_scroll_area = VerticalScrollArea() + # self.plugin_scroll_area.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents) + self.ui.plugin_tab_layout.addWidget(self.ui.plugin_scroll_area) + # def on_close_notebook_tab(self): # self.tool_shapes.clear(update=True)