@@ -115,7 +115,6 @@ def parse_draw_segment(d):
115
115
"width" : d .GetWidth () * 1e-6
116
116
}
117
117
if shape == "circle" :
118
- print "Circle shape" , d .GetRadius () * 1e-6
119
118
return {
120
119
"type" : shape ,
121
120
"start" : start ,
@@ -137,11 +136,16 @@ def parse_draw_segment(d):
137
136
"width" : d .GetWidth () * 1e-6
138
137
}
139
138
if shape == "polygon" :
139
+ if hasattr (d , "GetPolyShape" ):
140
+ polygons = parse_poly_set (d .GetPolyShape ())
141
+ else :
142
+ print "Polygons not supported for KiCad 4"
143
+ polygons = []
140
144
return {
141
145
"type" : shape ,
142
146
"pos" : start ,
143
147
"angle" : d .GetParentModule ().GetOrientation () * 0.1 ,
144
- "polygons" : parse_poly_set ( d . GetPolyShape ())
148
+ "polygons" : polygons
145
149
}
146
150
147
151
@@ -169,12 +173,22 @@ def parse_text(d):
169
173
if d .GetClass () == "MTEXT" :
170
174
angle = d .GetDrawRotation () * 0.1
171
175
else :
172
- angle = d .GetTextAngle () * 0.1
176
+ if hasattr (d , "GetTextAngle" ):
177
+ angle = d .GetTextAngle () * 0.1
178
+ else :
179
+ angle = d .GetOrientation () * 0.1
180
+ print d , angle
181
+ if hasattr (d , "GetTextHeight" ):
182
+ height = d .GetTextHeight () * 1e-6
183
+ width = d .GetTextWidth () * 1e-6
184
+ else :
185
+ height = d .GetHeight () * 1e-6
186
+ width = d .GetWidth () * 1e-6
173
187
return {
174
188
"pos" : pos ,
175
189
"text" : d .GetText (),
176
- "height" : d . GetTextHeight () * 1e-6 ,
177
- "width" : d . GetTextWidth () * 1e-6 ,
190
+ "height" : height ,
191
+ "width" : width ,
178
192
"horiz_justify" : d .GetHorizJustify (),
179
193
"angle" : angle
180
194
}
@@ -268,13 +282,16 @@ def parse_modules(pcb):
268
282
size = normalize (p .GetSize ())
269
283
is_pin1 = p .GetPadName () == "1" or p .GetPadName () == "A1"
270
284
angle = p .GetOrientation () * - 0.1
271
- shape = {
285
+ shape_lookup = {
272
286
pcbnew .PAD_SHAPE_RECT : "rect" ,
273
287
pcbnew .PAD_SHAPE_OVAL : "oval" ,
274
288
pcbnew .PAD_SHAPE_CIRCLE : "circle" ,
275
- pcbnew .PAD_SHAPE_ROUNDRECT : "roundrect" ,
276
- pcbnew .PAD_SHAPE_CUSTOM : "custom" ,
277
- }.get (p .GetShape (), "unsupported" )
289
+ }
290
+ if hasattr (pcbnew , "PAD_SHAPE_ROUNDRECT" ):
291
+ shape_lookup [pcbnew .PAD_SHAPE_ROUNDRECT ] = "roundrect"
292
+ if hasattr (pcbnew , "PAD_SHAPE_CUSTOM" ):
293
+ shape_lookup [pcbnew .PAD_SHAPE_CUSTOM ] = "custom"
294
+ shape = shape_lookup .get (p .GetShape (), "unsupported" )
278
295
if shape == "unsupported" :
279
296
print "Unsupported pad shape " , p .GetShape ()
280
297
pad_dict = {
@@ -384,8 +401,10 @@ def main(pcb, launch_browser=True):
384
401
html_content = html_content .replace ('///PCBDATA///' , pcbdata_js )
385
402
with open (bom_file_name , "wt" ) as bom :
386
403
bom .write (html_content )
404
+ print "Created file" , bom_file_name
387
405
388
406
if launch_browser :
407
+ print "Opening it in browser"
389
408
open_file (os .path .join (bom_file_dir , 'ibom.html' ))
390
409
391
410
0 commit comments