summaryrefslogtreecommitdiff
path: root/mesh_dialog.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-07-12 19:56:02 +0200
committerjaseg <git@jaseg.de>2023-07-12 19:56:02 +0200
commit327778c99e615e4bd63cf3fc5899cee16883a3c5 (patch)
treec7d6152aa240c462fcc751b9777900364b3218ad /mesh_dialog.py
parent5e3313c34607be99e7f78500e89431c4624814d7 (diff)
downloadkimesh-327778c99e615e4bd63cf3fc5899cee16883a3c5.tar.gz
kimesh-327778c99e615e4bd63cf3fc5899cee16883a3c5.tar.bz2
kimesh-327778c99e615e4bd63cf3fc5899cee16883a3c5.zip
Sort footprint references in anchor dropdown
Diffstat (limited to 'mesh_dialog.py')
-rw-r--r--mesh_dialog.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/mesh_dialog.py b/mesh_dialog.py
index 7813489..c508608 100644
--- a/mesh_dialog.py
+++ b/mesh_dialog.py
@@ -6,6 +6,7 @@ import random
import math
from itertools import count, islice
import json
+import re
from os import path
import wx
@@ -85,7 +86,13 @@ class MeshPluginMainDialog(mesh_plugin_dialog.MainDialog):
if name == 'User.Eco1':
self.m_maskLayerChoice.SetSelection(i)
- for i, fp in enumerate(self.board.Footprints()):
+ def sort_key(fp):
+ ref = fp.GetReference()
+ parts = re.findall(r'[0-9]+|[^0-9]+', ref)
+ return tuple(int(part) if part.isnumeric() else part for part in parts)
+
+ self.fps = sorted(self.board.Footprints(), key=sort_key)
+ for i, fp in enumerate(self.fps):
ref = fp.GetReference()
self.m_anchorChoice.Append(ref)
if settings and ref == settings.anchor:
@@ -141,7 +148,7 @@ class MeshPluginMainDialog(mesh_plugin_dialog.MainDialog):
return path.join(path.dirname(self.board.GetFileName()), 'last_kimesh_settings.json')
def get_anchor(self):
- ref = str(list(self.board.Footprints())[self.m_anchorChoice.GetSelection()].GetReference())
+ ref = str(self.fps[self.m_anchorChoice.GetSelection()].GetReference())
footprints = [ fp for fp in self.board.Footprints() if fp.GetReference() == ref ]
if len(footprints) == 0:
wx.MessageDialog(self, f'Error: Could not find anchor footprint "{ref}".').ShowModal()