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.
This commit is contained in:
Roman PASSLER
2026-03-01 18:41:39 +01:00
parent 4e70342eae
commit a018575bbc

View File

@@ -190,9 +190,17 @@ class BoardOutlineCommands:
diameter_nm = int(diameter * scale) diameter_nm = int(diameter * scale)
pad_diameter_nm = int(pad_diameter * scale) if pad_diameter else diameter_nm + scale # 1mm larger by default 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 = pcbnew.FOOTPRINT(self.board)
module.SetReference(f"MH") module.SetReference(f"MH{next_num}")
module.SetValue(f"MountingHole_{diameter}mm") module.SetValue(f"MountingHole_{diameter}mm")
# Create the pad for the hole # Create the pad for the hole