- in Drilling Plugin fixed a situation when having tools with the same diameter will get them multiplied by the number of those tools
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user