Last active
December 21, 2021 13:48
-
-
Save L0laapk3/284649f7b2c3100c2956782ca9fc33b9 to your computer and use it in GitHub Desktop.
Easy placement of kicad components calculated from reference number. example for SN410501N
This file contains 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
import re | |
file = "kicad/7seg_clock.kicad_pcb" | |
def place(m): | |
ref = int(m.group(3)) - 1 | |
x = ref // 10 | |
y = ref % 10 | |
x *= 25.25 | |
y *= 19.25 | |
return f"{m.group(1)}{x} {y}{m.group(2)}{m.group(3)}" | |
with open(file, "r+") as f: | |
text = f.read() | |
text = re.sub(r'(module SN410501N.+\n.+at ).+(\)\n.+\n.+U)(\d+)', place, text) | |
f.seek(0) | |
f.write(text) | |
f.truncate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment