From a018575bbc19222f8d0eeae918617d03f3a03a21 Mon Sep 17 00:00:00 2001 From: Roman PASSLER Date: Sun, 1 Mar 2026 18:41:39 +0100 Subject: [PATCH] fix(mounting-hole): generate unique references MH1, MH2, etc. All mounting holes were assigned the same reference "MH", violating PCB conventions and causing conflicts. Now queries existing footprints to find the next available MH number. --- python/commands/board/outline.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/python/commands/board/outline.py b/python/commands/board/outline.py index b0bf332..e826000 100644 --- a/python/commands/board/outline.py +++ b/python/commands/board/outline.py @@ -190,9 +190,17 @@ class BoardOutlineCommands: diameter_nm = int(diameter * scale) pad_diameter_nm = int(pad_diameter * scale) if pad_diameter else diameter_nm + scale # 1mm larger by default - # Create footprint for mounting hole + # Create footprint for mounting hole with unique reference + existing_mh = [ + fp.GetReference() for fp in self.board.GetFootprints() + if fp.GetReference().startswith("MH") + ] + next_num = 1 + while f"MH{next_num}" in existing_mh: + next_num += 1 + module = pcbnew.FOOTPRINT(self.board) - module.SetReference(f"MH") + module.SetReference(f"MH{next_num}") module.SetValue(f"MountingHole_{diameter}mm") # Create the pad for the hole