-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy patheagleForms.py
61 lines (55 loc) · 2.09 KB
/
eagleForms.py
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 dialogs"
__author__="oddtopus"
__url__="github.com/oddtopus/flamingo"
__license__="LGPL 3"
import FreeCAD,FreeCADGui,eagleCmd
from PySide.QtCore import *
from PySide.QtGui import *
class eagleForm(QWidget):
'prototype dialog for PCB components positioning'
def __init__(self,winTitle='.brd import and displacement on PCB'):
'''
A FreeCAD-PCB simple extension
'''
super(eagleForm,self).__init__()
self.move(QPoint(100,250))
self.setWindowFlags(Qt.WindowStaysOnTopHint)
self.setWindowTitle(winTitle)
self.mainHL=QHBoxLayout()
self.setLayout(self.mainHL)
self.stuffList=QListWidget()
self.stuffList.setMaximumWidth(120)
self.stuffList.setCurrentRow(0)
self.mainHL.addWidget(self.stuffList)
self.stuffDictList=[]
self.secondCol=QWidget()
self.secondCol.setLayout(QVBoxLayout())
self.btn1=QPushButton('Import .brd')
self.btn1.setDefault(True)
self.btn1.setFocus()
self.secondCol.layout().addWidget(self.btn1)
self.btn2=QPushButton('Place all')
self.secondCol.layout().addWidget(self.btn2)
self.mainHL.addWidget(self.secondCol)
# check the model
if 'Parts' in [o.Label for o in FreeCAD.activeDocument().Objects]:
if len(FreeCAD.activeDocument().Parts.OutList)>0:
FreeCAD.Console.PrintMessage('Parts has '+str(len(FreeCAD.activeDocument().Parts.OutList))+' components\n')
else:
FreeCAD.Console.PrintWarning('Parts has no components\n')
else:
FreeCAD.Console.PrintError('No group "Parts" found\n')
# function assignment
self.btn1.clicked.connect(self.importBrd)
self.btn2.clicked.connect(self.placeStuff)
# show dialog
self.show()
def importBrd(self):
self.stuffDictList=eagleCmd.brdIn()
for comp in FreeCAD.activeDocument().Parts.OutList:
keysUpperCaseList=[k.upper() for k in self.stuffDictList.keys()]
if comp.Label.upper() in keysUpperCaseList:
self.stuffList.addItem(comp.Label.upper())
def placeStuff(self):
eagleCmd.brdCompare(self.stuffDictList)