ViaStitching 1.3: checks against poured copper, snap grid, skip markers

- clearances checked with exact shapes (round via) against pads, tracks,
  vias, copper drawings, other zones' poured copper and keepouts;
  Rectangular no longer uses square box tests
- Outline follows the poured copper edge, vias on the grid
- same-net pads: only thermal relief gap and hole-to-hole spacing
- optional zone refill before placing vias
- snap grid option (disables Grid Origin choice)
- via group mode: per net, per net and pattern, new group per run
- optional markers of skipped vias on User.Drawings with reason letter
- option to keep vias out of footprint references
- warning when "Only under selected Zone" has no zone of the net selected
- dialog: options in two columns, narrower window
This commit is contained in:
Zdeněk committed 2026-11-16 18:42:58 +01:00
1 parent ae5f101eda
commit bb6815b9b2
6 files changed
+1406 -309

No files matched your search

+44 -6
View File
@@ -75,10 +75,15 @@ def SaveSettings(dlg):
"net": dlg.m_cbNet.GetStringSelection(),
"fill_type": dlg.m_cbFillType.GetStringSelection(),
"grid_type": dlg.m_cbGridType.GetStringSelection(),
"snap": dlg.m_SnapMM.GetValue(),
"group_mode": dlg.m_cbGroupMode.GetStringSelection(),
"random": dlg.m_Random.IsChecked(),
"only_selected": dlg.m_only_selected.IsChecked(),
"via_through_areas": dlg.m_viaThroughAreas.IsChecked(),
"same_net_tracks": dlg.m_sameNetTracks.IsChecked(),
"refill_zones": dlg.m_refillZones.IsChecked(),
"mark_skipped": dlg.m_markSkipped.IsChecked(),
"skip_reference": dlg.m_skipReference.IsChecked(),
}
try:
with open(SettingsFile(), "w") as f:
@@ -89,23 +94,44 @@ def SaveSettings(dlg):
def ApplySettings(dlg, data):
for key, ctrl in (("size", dlg.m_SizeMM), ("drill", dlg.m_DrillMM),
("clearance", dlg.m_ClearanceMM), ("step", dlg.m_StepMM)):
("clearance", dlg.m_ClearanceMM), ("step", dlg.m_StepMM),
("snap", dlg.m_SnapMM)):
if isinstance(data.get(key), str) and data[key].strip():
ctrl.SetValue(data[key])
for key, ctrl in (("random", dlg.m_Random), ("only_selected", dlg.m_only_selected),
("via_through_areas", dlg.m_viaThroughAreas),
("same_net_tracks", dlg.m_sameNetTracks)):
("same_net_tracks", dlg.m_sameNetTracks),
("refill_zones", dlg.m_refillZones),
("mark_skipped", dlg.m_markSkipped),
("skip_reference", dlg.m_skipReference)):
if isinstance(data.get(key), bool):
ctrl.SetValue(data[key])
for key, ctrl in (("fill_type", dlg.m_cbFillType), ("grid_type", dlg.m_cbGridType)):
for key, ctrl in (("fill_type", dlg.m_cbFillType), ("grid_type", dlg.m_cbGridType),
("group_mode", dlg.m_cbGroupMode)):
if isinstance(data.get(key), str):
index = ctrl.FindString(data[key])
if index != wx.NOT_FOUND:
ctrl.SetSelection(index)
def ParseSnap(text):
"""Snap grid in mm from the dialog; empty / invalid / <= 0 means off."""
try:
value = float(text.replace(',', '.'))
except ValueError:
return 0.0
return value if value > 0 else 0.0
class FillAreaDialogEx(FillAreaDialog.FillAreaDialog):
def onSnapChanged(self, event):
self.UpdateGridTypeState()
def UpdateGridTypeState(self):
# Snap grid always starts at the board grid origin => the origin choice does not apply
self.m_cbGridType.Enable(ParseSnap(self.m_SnapMM.GetValue()) == 0)
def onDeleteClick(self, event):
return self.EndModal(wx.ID_DELETE)
@@ -113,7 +139,7 @@ class FillAreaDialogEx(FillAreaDialog.FillAreaDialog):
class FillAreaAction(pcbnew.ActionPlugin):
def defaults(self):
self.name = "Via Stitching Generator 1.2"
self.name = "Via Stitching Generator 1.3"
self.category = "Modify PCB"
self.description = "Via Stitching for PCB Zone"
self.icon_file_name = os.path.join(os.path.dirname(__file__), "./stitching-vias.png")
@@ -132,15 +158,18 @@ class FillAreaAction(pcbnew.ActionPlugin):
a.m_SizeMM.SetValue(str(pcbnew.ToMM(self.boardDesignSettings.GetCurrentViaSize())))
a.m_DrillMM.SetValue(str(pcbnew.ToMM(self.boardDesignSettings.GetCurrentViaDrill())))
a.m_ClearanceMM.SetValue(str(pcbnew.ToMM(self.boardDesignSettings.GetSmallestClearanceValue())))
a.SetMinSize(a.GetSize())
# Grow the default size only if the content needs more (fonts / DPI differ between systems)
best = a.GetBestSize()
a.SetSize(wx.Size(max(a.GetSize().x, best.x), max(a.GetSize().y, best.y)))
a.SetMinSize(best)
settings = LoadSettings()
ApplySettings(a, settings)
last_net = settings.get("net")
PopulateNets(last_net if isinstance(last_net, str) else None, a)
a.UpdateGridTypeState()
modal_result = a.ShowModal()
if modal_result == wx.ID_OK:
wx.LogMessage('Via Stitching')
SaveSettings(a)
if 1: # try:
fill = FillArea.FillArea()
@@ -156,10 +185,19 @@ class FillAreaAction(pcbnew.ActionPlugin):
fill.SetRandom(a.m_Random.IsChecked())
fill.SetViaThroughAreas(a.m_viaThroughAreas.IsChecked())
fill.SetGridType(a.m_cbGridType.GetStringSelection())
fill.SetSnapMM(ParseSnap(a.m_SnapMM.GetValue()))
fill.SetFillType(a.m_cbFillType.GetStringSelection())
fill.SetGroupMode(a.m_cbGroupMode.GetStringSelection())
fill.SetSameNetTracks(a.m_sameNetTracks.IsChecked())
fill.SetRefillZones(a.m_refillZones.IsChecked())
fill.SetMarkSkipped(a.m_markSkipped.IsChecked())
fill.SetSkipReference(a.m_skipReference.IsChecked())
if a.m_only_selected.IsChecked():
fill.OnlyOnSelectedArea()
if not fill.CheckSelectedZone():
a.Destroy()
return # warning shown, nothing logged => no extra log window
wx.LogMessage('Via Stitching')
fill.Run()
else: # except Exception:
wx.MessageDialog(None, "Invalid parameter")