Foot gen script now sorts footprints by the order they are listed in the pcb text

This commit is contained in:
andrewc
2024-03-14 13:22:38 +10:00
parent e927efbc22
commit 06a2385777

View File

@@ -93,6 +93,7 @@ while len(pcb.Footprints()) > 1:
foot = pcb.Footprints().pop() foot = pcb.Footprints().pop()
if foot.GetReference() in new_foots.keys(): if foot.GetReference() in new_foots.keys():
saved.append(foot) saved.append(foot)
saved.sort(key=lambda foot: list(new_foots.keys()).index(foot.GetReference()))
# just in case # just in case
pcb.DeleteAllFootprints() pcb.DeleteAllFootprints()
# Add them back # Add them back
@@ -149,8 +150,8 @@ for foot in saved:
pcb.Add(load_foot) pcb.Add(load_foot)
# Sort by Y # # Sort by Y
sorted_foots.sort(key=lambda foot: foot[0].GetY()) # sorted_foots.sort(key=lambda foot: foot[0].GetY())
# Export the step file # Export the step file
os.system("kicad-cli pcb export step -f --subst-models --user-origin " + str(ToMM(brd_cent.x)) + "x" + str(ToMM(brd_cent.y)) + "mm -o /tmp/dummy.step " + sys.argv[1]) os.system("kicad-cli pcb export step -f --subst-models --user-origin " + str(ToMM(brd_cent.x)) + "x" + str(ToMM(brd_cent.y)) + "mm -o /tmp/dummy.step " + sys.argv[1])