ViaStitching 1.2: KiCad 10 support, remember last values

- numeric KiCad version check (string compare broke on 10.x)
- GetBoardPolygonOutlines, PCB_VIA.GetWidth, PAD.GetEffectivePolygon: KiCad 10 API
- default grid 2.5 mm
- dialog values saved to ViaStitching.json in KiCad user settings dir
- net list: only nets with a zone, GND first and preselected
- add metadata.json
- README: KiCad 10
This commit is contained in:
Zdeněk committed 2026-11-15 10:23:11 +01:00
1 parent 46e744d886
commit ae5f101eda
4 files changed
+171 -18

No files matched your search

+43 -7
View File
@@ -38,6 +38,37 @@ def wxPrint(msg):
wx.LogMessage(msg)
def KicadMajorVersion():
"""Return KiCad major version as int (string compare breaks for 10+)."""
try:
return int(str(Version()).lstrip("(").split(".")[0])
except (ValueError, IndexError):
return 99
def ViaWidth(via):
"""Via copper width; KiCad 10+ padstacks need a layer argument."""
try:
return via.GetWidth(F_Cu)
except TypeError:
return via.GetWidth()
def PadCollidesShape(pad, shape):
"""Test pad copper polygon vs. shape; KiCad 10+ needs a layer argument."""
try:
layers = list(pad.GetLayerSet().CuStack())
if not layers:
return False
for layer in layers:
if pad.GetEffectivePolygon(layer).Collide(shape):
return True
return False
except TypeError:
# KiCad 9 and older
return pad.GetEffectivePolygon().Collide(shape)
#
if sys.version[0] == "2": # maui
None
@@ -297,7 +328,7 @@ STEP = '-'
for i in range(self.pcb.GetAreaCount()):
area = self.pcb.GetArea(i)
# No more making a real refill since it's crashing KiCad
if Version() < "7":
if KicadMajorVersion() < 7:
None
else:
area.SetNeedRefill(True)
@@ -329,7 +360,7 @@ STEP = '-'
point_to_test = VECTOR2I(int(via.PosX + dx), int(via.PosY + dy))
hit_test_area = False
if Version() < "7":
if KicadMajorVersion() < 7:
# below 7.0.0
for layer_id in area.GetLayerSet().CuStack():
hit_test_area = hit_test_area or area.HitTestFilledArea(layer_id, point_to_test) # Collides with a filled area
@@ -417,7 +448,7 @@ STEP = '-'
def CheckViaDistance(self, p, via, outline):
p2 = VECTOR2I(via.GetPosition())
dist = self.clearance + self.size / 2 + via.GetWidth() / 2
dist = self.clearance + self.size / 2 + ViaWidth(via) / 2
# If via in same outline, then apply bigger space
if outline.Collide(p2):
@@ -481,7 +512,7 @@ STEP = '-'
# For KiCad >= 7, zone.Outline() may return an empty SHAPE_POLY_SET for inner-layer
# zones. We therefore try to build the polygon from points directly.
zone_poly = SHAPE_POLY_SET()
if Version() < "7":
if KicadMajorVersion() < 7:
for layer_id in zone.GetLayerSet().CuStack():
z = zone.RawPolysList(layer_id)
if z.OutlineCount() > 0:
@@ -667,7 +698,12 @@ STEP = '-'
# Get the board outline and size with
board_edge = SHAPE_POLY_SET()
self.pcb.GetBoardPolygonOutlines(board_edge)
try:
# KiCad 10+: aInferOutlineIfNecessary is a required argument
self.pcb.GetBoardPolygonOutlines(board_edge, True)
except TypeError:
# KiCad 9 and older
self.pcb.GetBoardPolygonOutlines(board_edge)
b_clearance = max(self.pcb.GetDesignSettings().m_CopperEdgeClearance, self.clearance) + self.size
board_edge.Deflate(int(b_clearance), CORNER_STRATEGY_ROUND_ALL_CORNERS, FromMM(0.01))
@@ -706,7 +742,7 @@ STEP = '-'
offset = 0 # Use an exact zone match
point_to_test = VECTOR2I(int(current_x), int(current_y))
hit_test_area = False
if Version() < "7":
if KicadMajorVersion() < 7:
# below 7.0.0
hit_test_area = area.HitTestFilledArea(area.GetLayer(), VECTOR2I(point_to_test), int(offset)) # Collides with a filled area
else:
@@ -774,7 +810,7 @@ STEP = '-'
m.SetViaType(VIATYPE_THROUGH)
m.SetDrill(int(self.drill))
m.SetWidth(int(self.size))
if pad.GetEffectivePolygon(pad.GetLayer()).Collide(m.GetEffectiveShape()):
if PadCollidesShape(pad, m.GetEffectiveShape()):
rectangle[x][y] = self.REASON_PAD
except: