Created
January 21, 2014 22:00
-
-
Save omerk/8549302 to your computer and use it in GitHub Desktop.
Converts rectangles to SMD pads in Eagle 6.x libraries. Since this is essentially a quick hack, you should isolate the package you are working with into a new library and copy the resultant pad data into the file manually.
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 sys | |
from xml.dom import minidom | |
def main(): | |
print "Opening " + sys.argv[1] | |
xmldoc = minidom.parse(sys.argv[1]) | |
rects = xmldoc.getElementsByTagName('rectangle') | |
print "Found " + str(len(rects)) + " rectangles" | |
count = 0; | |
for r in rects: | |
dx = float(r.attributes['y2'].value) - float(r.attributes['y1'].value) | |
dy = float(r.attributes['x2'].value) - float(r.attributes['x1'].value) | |
x = (dy / 2) + float(r.attributes['x1'].value) | |
y = (dx / 2) + float(r.attributes['y1'].value) | |
print '<smd name="RP${0}" x="{1}" y="{2}" dx="{3}" dy="{4}" layer="16" rot="R90"/>'.format(count, x, y, dx, dy) | |
count += 1 | |
if __name__ == "__main__": | |
if len(sys.argv) < 2: | |
print "Usage: " + sys.argv[0] + " <library_name>" | |
sys.exit(1) | |
else: | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment