-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy patheagleCmd.py
More file actions
61 lines (56 loc) · 1.61 KB
/
eagleCmd.py
File metadata and controls
61 lines (56 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#(c) 2016 R. T. LGPL: part of Flamingo tools w.b. for FreeCAD
__title__="eagleTools functions"
__author__="oddtopus"
__url__="github.com/oddtopus/flamingo"
__license__="LGPL 3"
import xml.etree.ElementTree as et
import FreeCAD as App
from PySide import QtGui as qg
doc=App.activeDocument()
try:
if len(doc.Parts.OutList)>0:
App.Console.PrintMessage('Parts has '+str(len(doc.Parts.OutList))+' components\n')
else:
App.Console.PrintMessage('Parts has no components')
except:
App.Console.PrintWarning('no group "Parts" found\n')
def brdIn():
board=qg.QFileDialog().getOpenFileName() [0]
try:
radice=et.parse(board).getroot()
el=[]
pos=[]
for ramo in radice.iter('element'):
el.append(ramo)
for e in el:
x=float(e.attrib['x'])
y=float(e.attrib['y'])
if ('rot' in e.attrib) and (e.attrib['rot'].lstrip('R').isdigit()):
rot=float(e.attrib['rot'].lstrip('R'))
else:
rot=0.0
pos.append([e.attrib['name'],[x,y,rot]])
dpos=dict(pos)
for k in dpos.keys():
App.Console.PrintMessage(str(k)+'\t'+str(dpos[k])+'\n')
return dpos
except:
App.Console.PrintMessage('no such file\n')
def brdCompare(pos):
doc=App.activeDocument()
klist=[]
for k in pos.keys():
klist.append(k.upper())
for comp in doc.Parts.OutList:
if comp.Label.upper() in klist:
print(str(comp.Label)+' is in pos')
try:
comp.X=pos[str(comp.Label)][0]
comp.Y=pos[str(comp.Label)][1]
comp.Rot=pos[str(comp.Label)][2]
except:
comp.X=pos[str(comp.Label.upper())][0]
comp.Y=pos[str(comp.Label.upper())][1]
comp.Rot=pos[str(comp.Label.upper())][2]
else:
print (str(comp.Label)+' is not in pos')