Skip to content

Commit

Permalink
Fix some crash due to refill zone. Fix #61
Browse files Browse the repository at this point in the history
  • Loading branch information
jsreynaud committed Jun 8, 2023
1 parent 076e720 commit 680af4e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
31 changes: 16 additions & 15 deletions ViaStitching/FillArea.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from __future__ import print_function
from pcbnew import *
from builtins import abs
from builtins import abs
import sys
import tempfile
import shutil
Expand Down Expand Up @@ -272,9 +272,14 @@ def AddVia(self, position, x, y):
def RefillBoardAreas(self):
for i in range(self.pcb.GetAreaCount()):
area = self.pcb.GetArea(i)
area.UnFill()
filler = ZONE_FILLER(self.pcb)
filler.Fill(self.pcb.Zones())
# No more making a real refill since it's crashing KiCad
if Version() < '7':
None
else:
area.SetNeedRefill(True)
# area.UnFill()
# filler = ZONE_FILLER(self.pcb)
# filler.Fill(self.pcb.Zones())

def CheckViaInAllAreas(self, via, all_areas):
'''
Expand Down Expand Up @@ -316,7 +321,7 @@ def CheckViaInAllAreas(self, via, all_areas):
hit_test_zone = area.HitTestInsideZone(VECTOR2I(point_to_test)) # Is inside a zone (e.g. KeepOut/Rules)
except:
hit_test_zone = False
wxPrint('exception: missing HitTestInsideZone: To Be Fixed')
# wxPrint('exception: missing HitTestInsideZone: To Be Fixed (not available in kicad 7.0)')
# hit_test_zone = area.HitTest(point_to_test)

# Is inside a zone (e.g. KeepOut/Rules with via exlusion) kicad
Expand Down Expand Up @@ -417,14 +422,11 @@ def AddViasAlongOutline(self, outline, outline_parent, all_vias, offset=0):
return via_placed

def ConcentricFillVias(self):
wxPrint("Refill all zones")
self.RefillBoardAreas()

wxPrint("Calculate placement areas")

zones = [zone for zone in self.pcb.Zones() if zone.GetNetname() == self.netname]
self.parent_area = zones[0]

# Create set of polygons where fill zones overlap on all layers
poly_set = None
for layer_id in self.pcb.GetEnabledLayers().CuStack():
Expand Down Expand Up @@ -476,11 +478,10 @@ def ConcentricFillVias(self):
else:
poly_set = SHAPE_POLY_SET()

wxPrint("Refill all zones")
self.RefillBoardAreas()

msg = "{:d} vias placed\n".format(via_placed)
wxPrint(msg+"Done!")
msg = "Done. {:d} vias placed. You have to refill all your pcb's areas/zones !!!".format(via_placed)
wxPrint(msg)

return via_placed

Expand Down Expand Up @@ -667,7 +668,7 @@ def Run(self):
if self.debug:
print("%s: Line %u" % (time.time(), currentframe().f_lineno))
for pad in all_pads:
local_offset = max(pad.GetOwnClearance(UNDEFINED_LAYER,""), self.clearance, max_target_area_clearance) + (self.size / 2)
local_offset = max(pad.GetOwnClearance(UNDEFINED_LAYER, ""), self.clearance, max_target_area_clearance) + (self.size / 2)
max_size = max(pad.GetSize().x, pad.GetSize().y)

start_x = int(floor(((pad.GetPosition().x - (max_size / 2.0 + local_offset)) - origin.x) / l_clearance))
Expand Down Expand Up @@ -728,7 +729,7 @@ def Run(self):
opx = stop_x
opy = stop_y

clearance = max(track.GetOwnClearance(UNDEFINED_LAYER,""), self.clearance, max_target_area_clearance) + \
clearance = max(track.GetOwnClearance(UNDEFINED_LAYER, ""), self.clearance, max_target_area_clearance) + \
(self.size / 2) + (track.GetWidth() / 2)

start_x = int(floor(((start_x - clearance) - origin.x) / l_clearance))
Expand Down Expand Up @@ -809,8 +810,8 @@ def Run(self):

if self.filename:
self.pcb.Save(self.filename)
msg = "{:d} vias placed\n".format(via_placed)
wxPrint(msg+"Done!")
msg = "Done. {:d} vias placed. You have to refill all your pcb's areas/zones !!!".format(via_placed)
wxPrint(msg)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion ViaStitching/FillAreaAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def Run(self):
PopulateNets("GND", a)
modal_result = a.ShowModal()
if modal_result == wx.ID_OK:
wx.LogMessage('Via Stitching: Version 1.5')
wx.LogMessage('Via Stitching')
if 1: # try:
fill = FillArea.FillArea()
fill.SetStepMM(float(a.m_StepMM.GetValue().replace(',', '.')))
Expand Down

0 comments on commit 680af4e

Please sign in to comment.