Skip to content

Commit

Permalink
Add 'solderMaskMargin' parameter to Tooling
Browse files Browse the repository at this point in the history
  • Loading branch information
jbower-fb authored and yaqwsx committed Feb 20, 2024
1 parent e0a347a commit 74be0db
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
11 changes: 8 additions & 3 deletions kikit/panelize.py
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,9 @@ def makeCutsToLayer(self, cuts, layer=Layer.Cmts_User, prolongation=fromMm(0)):

def addNPTHole(self, position: VECTOR2I, diameter: KiLength,
paste: bool=False, ref: Optional[str]=None,
excludedFromPos: bool=False) -> None:
excludedFromPos: bool=False,
solderMaskMargin: Optional[KiLength] = None,
) -> None:
"""
Add a drilled non-plated hole to the position (`VECTOR2I`) with given
diameter. The paste option allows to place the hole on the paste layers.
Expand All @@ -1523,6 +1525,8 @@ def addNPTHole(self, position: VECTOR2I, diameter: KiLength,
for pad in footprint.Pads():
pad.SetDrillSize(toKiCADPoint((diameter, diameter)))
pad.SetSize(toKiCADPoint((diameter, diameter)))
if solderMaskMargin is not None:
footprint.SetLocalSolderMaskMargin(solderMaskMargin)
if paste:
layerSet = pad.GetLayerSet()
layerSet.AddLayer(Layer.F_Paste)
Expand Down Expand Up @@ -1595,7 +1599,7 @@ def addCornerFiducials(self, fidCount: int, horizontalOffset: KiLength,
paste, ref = f"KiKit_FID_B_{i+1}")

def addCornerTooling(self, holeCount, horizontalOffset, verticalOffset,
diameter, paste=False):
diameter, paste=False, solderMaskMargin: Optional[KiLength]=None):
"""
Add up to 4 tooling holes to the top-left, top-right, bottom-left and
bottom-right corner of the board (in this order). This function expects
Expand All @@ -1604,7 +1608,8 @@ def addCornerTooling(self, holeCount, horizontalOffset, verticalOffset,
The offsets are measured from the outer edges of the substrate.
"""
for i, pos in enumerate(self.panelCorners(horizontalOffset, verticalOffset)[:holeCount]):
self.addNPTHole(pos, diameter, paste, ref=f"KiKit_TO_{i+1}", excludedFromPos=False)
self.addNPTHole(pos, diameter, paste, ref=f"KiKit_TO_{i+1}", excludedFromPos=False,
solderMaskMargin=solderMaskMargin)

def addMillFillets(self, millRadius):
"""
Expand Down
5 changes: 3 additions & 2 deletions kikit/panelize_ui_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,12 @@ def buildTooling(preset, panel):
hoffset, voffset = toolingPreset["hoffset"], toolingPreset["voffset"]
diameter = toolingPreset["size"]
paste = toolingPreset["paste"]
soldermaskmargin = toolingPreset["soldermaskmargin"]
if type == "3hole":
panel.addCornerTooling(3, hoffset, voffset, diameter, paste)
panel.addCornerTooling(3, hoffset, voffset, diameter, paste, soldermaskmargin)
return
if type == "4hole":
panel.addCornerTooling(4, hoffset, voffset, diameter, paste)
panel.addCornerTooling(4, hoffset, voffset, diameter, paste, soldermaskmargin)
return
raise PresetError(f"Unknown type '{type}' of tooling specification.")
except KeyError as e:
Expand Down
3 changes: 3 additions & 0 deletions kikit/panelize_ui_sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ def ppFraming(section):
"paste": SBool(
typeIn(["3hole", "4hole", "plugin"]),
"Include holes on the paste layer"),
"soldermaskmargin": SLength(
typeIn(["3hole", "4hole", "plugin"]),
"Solder mask expansion/margin"),
"code": SPlugin(
plugin.ToolingPlugin,
typeIn(["plugin"]),
Expand Down
1 change: 1 addition & 0 deletions kikit/resources/panelizePresets/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"voffset": "0mm",
"size": "2mm",
"paste": false,
"soldermaskmargin": "0mm",
"code": "none",
"arg": ""
},
Expand Down
5 changes: 3 additions & 2 deletions kikit/resources/panelizePresets/jlcTooling.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"tooling": {
"style": "3hole",
"size": "1.152mm",
"paste": false
"paste": false,
"soldermaskmargin": "1.3mm"
}
}
}

0 comments on commit 74be0db

Please sign in to comment.