Skip to content

Commit f3617a3

Browse files
committed
[BoardView][Added] Workaround for KiCad bug 23216
1 parent 9daee31 commit f3617a3

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

kibot/out_boardview.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def natural_sort_key(s):
4444
for text in re.compile('([0-9]+)').split(s)])
4545

4646

47-
def get_board_polygon_outlines(pcb):
47+
def convert_brd(pcb, brd, do_sort):
48+
# Board outline
49+
# <-- This code can't be a function or we crash pcbnew API
4850
outlines = SHAPE_POLY_SET()
4951
if GS.ki5:
5052
pcb.GetBoardPolygonOutlines(outlines, "")
@@ -57,12 +59,7 @@ def get_board_polygon_outlines(pcb):
5759
pcb.GetBoardPolygonOutlines(outlines)
5860
outline = outlines.Outline(0)
5961
outline_points = [outline.GetPoint(n) for n in range(outline.GetPointCount())]
60-
return outline, outline_points
61-
62-
63-
def convert_brd(pcb, brd, do_sort):
64-
# Board outline
65-
outline, outline_points = get_board_polygon_outlines(pcb)
62+
# <-- End
6663
outline_maxx = max((p.x for p in outline_points))
6764
outline_maxy = max((p.y for p in outline_points))
6865

@@ -176,7 +173,20 @@ def get_type_name(m):
176173
def convert_bvr(pcb, bvr):
177174
bvr.write("BVRAW_FORMAT_3\n")
178175

179-
outline, outline_points = get_board_polygon_outlines(pcb)
176+
# <-- This code can't be a function or we crash pcbnew API
177+
outlines = SHAPE_POLY_SET()
178+
if GS.ki5:
179+
pcb.GetBoardPolygonOutlines(outlines, "")
180+
outline = outlines.Outline(0)
181+
outline_points = [outline.Point(n) for n in range(outline.PointCount())]
182+
else:
183+
if GS.ki10:
184+
pcb.GetBoardPolygonOutlines(outlines, True)
185+
else:
186+
pcb.GetBoardPolygonOutlines(outlines)
187+
outline = outlines.Outline(0)
188+
outline_points = [outline.GetPoint(n) for n in range(outline.GetPointCount())]
189+
# <-- End
180190
max((p.x for p in outline_points))
181191
outline_maxy = max((p.y for p in outline_points))
182192

0 commit comments

Comments
 (0)