From 9ec2ee2920051ddc14b90364251d40eed3824ae4 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 8 Nov 2022 15:59:59 +0200 Subject: [PATCH] - in Drilling Plugin fixed a situation when having tools with the same diameter will get them multiplied by the number of those tools --- CHANGELOG.md | 4 +++ appPlugins/ToolDrilling.py | 56 +++++++++++++++++++++++++------------- 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10c0810f..6c640478 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ CHANGELOG for FlatCAM Evo beta ================================================= +7.11.2022 + +- in Drilling Plugin fixed a situation when having tools with the same diameter will get them multiplied by the number of those tools + 6.11.2022 - if PikePDF module is not available then show an error but run the app (currently, for Python 3.11 is the only module not available) diff --git a/appPlugins/ToolDrilling.py b/appPlugins/ToolDrilling.py index e0e5504c..0a0af4bb 100644 --- a/appPlugins/ToolDrilling.py +++ b/appPlugins/ToolDrilling.py @@ -654,29 +654,47 @@ class ToolDrilling(AppTool, Excellon): self.app.log.debug("ToolDrilling.build_tool_ui()") self.ui_disconnect() - # order the tools by tool diameter if it's the case - sorted_tools = [] - for k, v in self.excellon_tools.items(): - sorted_tools.append(self.dec_format(float(v['tooldia']))) + # # order the tools by tool diameter if it's the case + # sorted_tools = [] + # for k, v in self.excellon_tools.items(): + # sorted_tools.append(self.dec_format(float(v['tooldia']))) + # + # order = self.ui.order_combo.get_value() + # if order == 1: # 'fwd' + # sorted_tools.sort(reverse=False) + # elif order == 2: # 'rev' + # sorted_tools.sort(reverse=True) + # else: + # pass + # + # # remake the excellon_tools dict in the order above + # new_id = 1 + # new_tools = {} + # for tooldia in sorted_tools: + # for old_tool in self.excellon_tools: + # if self.dec_format(float(self.excellon_tools[old_tool]['tooldia'])) == tooldia: + # new_tools[new_id] = deepcopy(self.excellon_tools[old_tool]) + # new_id += 1 order = self.ui.order_combo.get_value() if order == 1: # 'fwd' - sorted_tools.sort(reverse=False) - elif order == 2: # 'rev' - sorted_tools.sort(reverse=True) + new_tools = { + k: v for k, v in sorted(self.excellon_tools.items(), key=lambda it: it[1]['tooldia'], reverse=False) + } + for idx, v in enumerate(new_tools.values(), start=1): + self.excellon_tools[idx] = v + elif order == 2: # 'rev' + new_tools = { + k: v for k, v in sorted(self.excellon_tools.items(), key=lambda it: it[1]['tooldia'], reverse=True) + } + for idx, v in enumerate(new_tools.values(), start=1): + self.excellon_tools[idx] = v else: - pass - - # remake the excellon_tools dict in the order above - new_id = 1 - new_tools = {} - for tooldia in sorted_tools: - for old_tool in self.excellon_tools: - if self.dec_format(float(self.excellon_tools[old_tool]['tooldia'])) == tooldia: - new_tools[new_id] = deepcopy(self.excellon_tools[old_tool]) - new_id += 1 - - self.excellon_tools = new_tools + try: + self.excellon_tools = self.excellon_obj.tools + except AttributeError: + # when no object was loaded yet + pass if self.excellon_obj and self.excellon_tools: self.ui.exc_param_frame.setDisabled(False)