Last active
August 16, 2024 06:12
-
-
Save aerialist/f8460f6a21f7cef5e073e9d6c5efcd29 to your computer and use it in GitHub Desktop.
KiCad script to layout key switch matrix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# starting position | |
start_x = 42.4 | |
start_y = 30.3 | |
# distance between key switches | |
dx = 10.6 | |
dy = 10.1 | |
# number of rows and columns of the matrix | |
rown = 6 | |
coln = 15 | |
# Prefix of component reference | |
prefix = 'K' | |
import pcbnew | |
board = pcbnew.GetBoard() | |
for rowi in range(rown): | |
for coli in range(coln): | |
refn = ( coln * rowi + coli ) + 1 | |
reftxt = f"{prefix}{refn}" | |
x = start_x + dx*coli | |
y = start_y + dy*rowi | |
board.FindFootprintByReference(reftxt).SetPos(pcbnew.VECTOR2I_MM(x, y)) | |
pcbnew.Refresh() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment