When I change the wiring of Eagle's .brd file a little, the metal mask cannot be reused if the position of the part is also changed. I want to avoid this as much as possible, but I do not notice it when I change the wiring In order to avoid this, I wrote a program in Python that can check changes in the movement of parts that are invisible to the human eye, so this is a memo.
The "name" of the part before and after the change is the same.
We are taking advantage of Eagle's .brd file being an xml file. First, find the element with the same "name" attribute in the "element" element of the unmodified file and the "element" element of the modified file. After that, if the x or y coordinates are different, the name of the part and the (x, y) coordinates before and after the change are displayed, and if there is no problem, "No error" is displayed. ..
# -*- coding: utf-8 -*-
from xml.etree.ElementTree import *
def check(file1, file2):
c = 1
tree1 = parse(file1)
elem1 = tree1.getroot()
tree2 = parse(file2)
elem2 = tree2.getroot()
for e1 in elem1.getiterator("element"):
for e2 in elem2.getiterator("element"):
if e1.get("name", ) == e2.get("name", ):
if e1.get("x") != e2.get("x") or e1.get("y") != e2.get("y"):
print "Error"
print "Parts Name = " + e1.get("name")
print ("x1=" + e1.get("x")) * (e1.get("x") != e2.get("x"))
print ("x2=" + e2.get("x")) * (e1.get("x") != e2.get("x"))
print ("y1=" + e1.get("y")) * (e1.get("y") != e2.get("y"))
print ("y2=" + e2.get("y")) * (e1.get("y") != e2.get("y"))
c = 0
return c
if __name__ == "__main__":
file1 = raw_input() #Enter the path of the file before the change
file2 = raw_input() #Enter the path of the modified file
print "No error" * check(file1, file2)
Unlike the Linux "diff" command, it can be applied even if the order of "element" is different.
Reference: http://hikm.hatenablog.com/entry/20090206/1233950923
Recommended Posts