Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env python3
# coding=utf8
# Simple script to scale a KiCad footprint
# Usage:
# python <input.kicad_mod> <output.kicad_mod> <scale>
# Where scale is how much to scale (1 = 100%)
# Copyright (C) 2020, Uri Shaked.
import sys
import re
scale = float(sys.argv[3])
def scalexy(val):
x = float( * scale
y = float( * scale
return '(xy {} {})'.format(x, y)
with open(sys.argv[1], 'r') as in_file, open(sys.argv[2], 'w', newline='') as out_file:
for line in in_file:
line = re.sub(r'\(xy ([0-9-.]+) ([0-9-.]+)\)', scalexy, line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment