Skip to content

Commit

Permalink
Feat: Optionally use User.2 layer for alternative outline (#170)
Browse files Browse the repository at this point in the history
* feat: optionally use User.2 layer for alternative outline #169

* chore: fix table of layer override fields
  • Loading branch information
xingrz authored Oct 14, 2024
1 parent 79da28d commit 2a5e4a9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Options can be set in the dialog that appears when the plugin is invoked. They a

__Additional layers__: Comma-separated list of additional layers to include in the gerber archive.</br>
__Set User.1 as V-Cut layer__: Merge User.1 layer with the Edge-Cut layer in production.</br>
__Use User.2 for an alternative Edge-Cut layer__: Use the User.2 instead of the Edge-Cut layer for the board outline in production. This is useful if you need process edges or panelization during production but still want to keep the individual outline for prototyping, 3D model exports, or similar purposes.</br>
__Apply automatic translations__: Apply known translation fixes for common components.</br>
__Apply automatic fill for all zones__: Refill all zones before generation production files.</br>
__Exclude DNP components from BOM__: Exclude components the had been set a DNP from th BOM.</br>
Expand Down Expand Up @@ -138,14 +139,14 @@ Some footprints may have their components defined on the opposite layer to there
Values can be `top`, `bottom`, `t` or `b`.

#### Primary Fields*:
| 'JLCPCB Layer Override' |
| --- |
| 'JLCPCB Layer Override' |
| --- |

_The fields will be queried in the order denoted above._

#### Fallback Fields*:
| 'JlcLayerOverride' | 'JLCLayerOverride' |
| --- | --- |
| 'JlcLayerOverride' | 'JLCLayerOverride' |
| --- | --- |

_The fields will be queried in the order denoted above._

Expand Down
1 change: 1 addition & 0 deletions plugins/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
EXCLUDE_DNP_OPT = "EXCLUDE DNP"
OUTPUT_NAME_OPT = "OUTPUT NAME"
EXTEND_EDGE_CUT_OPT = "EXTEND_EDGE_CUT"
ALTERNATIVE_EDGE_CUT_OPT = "ALTERNATIVE_EDGE_CUT"
EXTRA_LAYERS = "EXTRA_LAYERS"
8 changes: 7 additions & 1 deletion plugins/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from .thread import ProcessThread
from .events import StatusEvent
from .options import AUTO_FILL_OPT, AUTO_TRANSLATE_OPT, EXCLUDE_DNP_OPT, EXTEND_EDGE_CUT_OPT, EXTRA_LAYERS
from .options import AUTO_FILL_OPT, AUTO_TRANSLATE_OPT, EXCLUDE_DNP_OPT, EXTEND_EDGE_CUT_OPT, ALTERNATIVE_EDGE_CUT_OPT, EXTRA_LAYERS
from .utils import load_user_options, save_user_options, get_layer_names


Expand All @@ -30,6 +30,7 @@ def __init__(self):
userOptions = load_user_options({
EXTRA_LAYERS: "",
EXTEND_EDGE_CUT_OPT: False,
ALTERNATIVE_EDGE_CUT_OPT: False,
AUTO_TRANSLATE_OPT: True,
AUTO_FILL_OPT: True,
EXCLUDE_DNP_OPT: False
Expand All @@ -47,6 +48,8 @@ def __init__(self):

self.mExtendEdgeCutsCheckbox = wx.CheckBox(self, label='Set User.1 as V-Cut layer')
self.mExtendEdgeCutsCheckbox.SetValue(userOptions[EXTEND_EDGE_CUT_OPT])
self.mAlternativeEdgeCutsCheckbox = wx.CheckBox(self, label='Use User.2 for alternative Edge-Cut layer')
self.mAlternativeEdgeCutsCheckbox.SetValue(userOptions[ALTERNATIVE_EDGE_CUT_OPT])
self.mAutomaticTranslationCheckbox = wx.CheckBox(self, label='Apply automatic translations')
self.mAutomaticTranslationCheckbox.SetValue(userOptions[AUTO_TRANSLATE_OPT])
self.mAutomaticFillCheckbox = wx.CheckBox(self, label='Apply automatic fill for all zones')
Expand All @@ -68,6 +71,7 @@ def __init__(self):
# boxSizer.Add(self.mOptionsSeparator, 0, wx.ALL, 5)
boxSizer.Add(self.mAdditionalLayersControl, 0, wx.ALL, 5)
boxSizer.Add(self.mExtendEdgeCutsCheckbox, 0, wx.ALL, 5)
boxSizer.Add(self.mAlternativeEdgeCutsCheckbox, 0, wx.ALL, 5)
boxSizer.Add(self.mAutomaticTranslationCheckbox, 0, wx.ALL, 5)
boxSizer.Add(self.mAutomaticFillCheckbox, 0, wx.ALL, 5)
boxSizer.Add(self.mExcludeDnpCheckbox, 0, wx.ALL, 5)
Expand All @@ -85,6 +89,7 @@ def onGenerateButtonClick(self, event):
options = dict()
options[EXTRA_LAYERS] = self.mAdditionalLayersControl.GetValue()
options[EXTEND_EDGE_CUT_OPT] = self.mExtendEdgeCutsCheckbox.GetValue()
options[ALTERNATIVE_EDGE_CUT_OPT] = self.mAlternativeEdgeCutsCheckbox.GetValue()
options[AUTO_TRANSLATE_OPT] = self.mAutomaticTranslationCheckbox.GetValue()
options[AUTO_FILL_OPT] = self.mAutomaticFillCheckbox.GetValue()
options[EXCLUDE_DNP_OPT] = self.mExcludeDnpCheckbox.GetValue()
Expand All @@ -94,6 +99,7 @@ def onGenerateButtonClick(self, event):
self.mOptionsLabel.Hide()
self.mAdditionalLayersControl.Hide()
self.mExtendEdgeCutsCheckbox.Hide()
self.mAlternativeEdgeCutsCheckbox.Hide()
self.mAutomaticTranslationCheckbox.Hide()
self.mAutomaticFillCheckbox.Hide()
self.mExcludeDnpCheckbox.Hide()
Expand Down
18 changes: 12 additions & 6 deletions plugins/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def update_zone_fills(self):
# Finally rebuild the connectivity db
self.board.BuildConnectivity()

def generate_gerber(self, temp_dir, extra_layers, extend_edge_cuts):
def generate_gerber(self, temp_dir, extra_layers, extend_edge_cuts, alternative_edge_cuts):
'''Generate the Gerber files.'''
settings = self.board.GetDesignSettings()
settings.m_SolderMaskMargin = 50000
Expand Down Expand Up @@ -77,13 +77,19 @@ def generate_gerber(self, temp_dir, extra_layers, extend_edge_cuts):
if self.board.IsLayerEnabled(layer_info[1]) or layer_info[0] in extra_layers:
plot_controller.SetLayer(layer_info[1])
plot_controller.OpenPlotfile(layer_info[0], pcbnew.PLOT_FORMAT_GERBER, layer_info[2])

if layer_info[1] == pcbnew.Edge_Cuts and hasattr(plot_controller, 'PlotLayers') and extend_edge_cuts:

if layer_info[1] == pcbnew.Edge_Cuts and hasattr(plot_controller, 'PlotLayers') and (extend_edge_cuts or alternative_edge_cuts):
seq = pcbnew.LSEQ()
# uses User_2 layer for alternative Edge_Cuts layer
if alternative_edge_cuts:
seq.push_back(pcbnew.User_2)
else:
seq.push_back(layer_info[1])
# includes User_1 layer with Edge_Cuts layer to allow V Cuts to be defined as User_1 layer
# available for KiCad 7.0.1+
seq = pcbnew.LSEQ()
seq.push_back(layer_info[1])
seq.push_back(pcbnew.User_1)
if extend_edge_cuts:
seq.push_back(layer_info[1])
seq.push_back(pcbnew.User_1)
plot_controller.PlotLayers(seq)
else:
plot_controller.PlotLayer()
Expand Down
2 changes: 1 addition & 1 deletion plugins/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def run(self):

# generate gerber
self.progress(20)
self.process_manager.generate_gerber(temp_dir_gerber, self.options[EXTRA_LAYERS], self.options[EXTEND_EDGE_CUT_OPT])
self.process_manager.generate_gerber(temp_dir_gerber, self.options[EXTRA_LAYERS], self.options[EXTEND_EDGE_CUT_OPT], self.options[ALTERNATIVE_EDGE_CUT_OPT])

# generate drill file
self.progress(30)
Expand Down

0 comments on commit 2a5e4a9

Please sign in to comment.