Skip to content

Commit

Permalink
Fix drawing PCBs without modules
Browse files Browse the repository at this point in the history
Drawing PCB without modules (for example edges only) were causing crash
due to module variable not being None (empty list). Using
pcbnew.MODULE_List.GetFirst() before iterating through elements seems to
be fixing this issue.
  • Loading branch information
adamws authored and yaqwsx committed Mar 7, 2021
1 parent 4e8f08b commit 3b96105
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pcbdraw/pcbdraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,8 @@ def get_board_substrate(board, colors, holes, back):
return container

def walk_components(board, back, export):
module = board.GetModules()
while True:
if not module:
return
module = board.GetModules().GetFirst()
while module:
# Top is for Eagle boards imported to KiCAD
if (str(module.GetLayerName()) in ["Back", "B.Cu"] and not back) or \
(str(module.GetLayerName()) in ["Top", "F.Cu"] and back):
Expand Down Expand Up @@ -486,7 +484,7 @@ def get_hole_mask(board):
bg.attrib["width"] = str(ki2dmil(bb.GetWidth()))
bg.attrib["height"] = str(ki2dmil(bb.GetHeight()))

module = board.GetModules()
module = board.GetModules().GetFirst()
while module:
if module.GetPadCount() == 0:
module = module.Next()
Expand Down

0 comments on commit 3b96105

Please sign in to comment.