-
Notifications
You must be signed in to change notification settings - Fork 1
/
pad.py
143 lines (129 loc) · 4 KB
/
pad.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
from colour import Colour
# https://github.com/KiCad/kicad-source-mirror/blob/93466fa1653191104c5e13231dfdc1640b272777/pcbnew/plugins/kicad/pcb_parser.cpp#L3530
# 0 pad
# 1 1/2/3
# 2 smd
# 3 rect
# 4
# 0 at
# 1 66.66
# 2 99.99
# 2 180
# 5
# 0 size
# 1 0.9
# 2 1.2
# 6
# 0 layers
# 1 F.Cu
# 2 F.Paste
# 3 F.Mask
# 7
# 0 net
# 1 16
# 2 Net-(D4-Pad1)
# 8
# 0 pinfunction
# 1 "A"
# 9
# 0 pintype
# 1 "passive"
pxToMM = 96 / 25.4
class Pad(object):
def __init__(self):
self.name = ''
#thru_hole, smd, connect, or np_thru_hole
self.attribute = ''
self.shape = ''
self.size = []
self.at = []
self.rect_delta = []
self.drill = []
self.layers = []
self.net = []
self.pinfunction = ''
self.pintype = ''
self.die_length = ''
self.solder_mask_margin = ''
self.solder_paste_margin = ''
self.solder_paste_margin_ratio = ''
self.clearance = ''
self.zone_connect = ''
self.thermal_width = ''
self.thermal_gap = ''
self.roundrect_rratio = ''
self.chamfer_ratio = ''
self.chamfer = ''
self.property = ''
self.options = ''
self.primitives = ''
self.remove_unused_layers = ''
self.keep_end_layers = ''
self.tstamp = ''
def From_PCB(self, input):
at = []
size = []
layers = []
roundrect_rratio = ''
net = ''
rotate = ''
if input[0] != 'pad':
assert False,"Pad: Not a pad"
return None
self.name = input[1]
self.attribute = input[2]
self.shape = input[3]
for item in input[4:]:
if item[0] == 'size':
self.size = [float(item[1]),float(item[2])]
if item[0] == 'at':
for at in item[1:]:
self.at.append(float(at))
#Todo: proper handling for many of these
if item[0] == 'rect_delta':
self.rect_delta = item[1]
if item[0] == 'drill':
self.drill = item[1]
if item[0] == 'layers':
for layer in item[1:]:
self.layers.append(layer)
if item[0] == 'net':
self.net = item[1:]
if item[0] == 'pinfunction':
self.pinfunction = item[1]
if item[0] == 'pintype':
self.pintype = item[1]
if item[0] == 'die_length':
self.die_length = item[1]
if item[0] == 'solder_mask_margin':
self.solder_mask_margin = item[1]
if item[0] == 'solder_paste_margin':
self.solder_paste_margin = item[1]
if item[0] == 'solder_paste_margin_ratio':
self.solder_paste_margin_ratio = item[1]
if item[0] == 'clearance':
self.clearance = item[1]
if item[0] == 'zone_connect':
self.zone_connect = item[1]
if item[0] == 'thermal_width':
self.thermal_width = item[1]
if item[0] == 'thermal_gap':
self.thermal_gap = item[1]
if item[0] == 'roundrect_rratio':
self.roundrect_rratio = item[1]
if item[0] == 'chamfer_ratio':
self.chamfer_ratio = item[1]
if item[0] == 'chamfer':
self.chamfer = item[1]
if item[0] == 'property':
self.property = item[1]
if item[0] == 'options':
self.options = item[1]
if item[0] == 'primitives':
self.primitives = item[1]
if item[0] == 'remove_unused_layers':
self.remove_unused_layers = item[1]
if item[0] == 'keep_end_layers':
self.keep_end_layers = item[1]
if item[0] == 'tstamp':
self.tstamp = item[1]