Compare commits

..

5 Commits

Author SHA1 Message Date
Benny Megidish bce98f72c3 chore: bump version 2024-02-29 15:42:26 +02:00
Benny Megidish 84e933b566 fix: extra layers filter 2024-02-28 07:53:29 +02:00
Benny Megidish 3714af0afb Merge branch 'master' of https://github.com/bennymeg/JLC-Plugin-for-KiCad 2024-02-27 22:42:03 +02:00
Benny Megidish b80a14dfbb feat: extra layers support (#113) 2024-02-27 22:41:54 +02:00
Maksim Salau bfa87db797 ifix: Use IsDNP() to get the DNP attribute in KiCAD v8 (#128)
`footprint_has_field(footprint, 'dnp')` returns `False` for DNP
components in KiCAD v8.

In KiCAD v8 the DNP flag is available via either the IsDNP() getter or
the FP_DNP attribute.

The added `getattr()` call turns into `footprint.IsDNP()` in KiCAD v8 or
`bool()` (which evaluates into `False`) in KiCAD v7 and earlier.
2024-02-27 22:16:20 +02:00
6 changed files with 27 additions and 8 deletions
+1 -1
View File
@@ -29,7 +29,7 @@
],
"versions": [
{
"version": "4.0.0",
"version": "4.1.0",
"status": "stable",
"kicad_version": "6.00"
}
+2
View File
@@ -52,3 +52,5 @@ plotPlan = [
("Edge.Cuts", pcbnew.Edge_Cuts, "Board Outline"),
("User.Comments", pcbnew.Cmts_User, "User Comments")
]
layers = [layer[0] for layer in plotPlan]
+2 -1
View File
@@ -1,2 +1,3 @@
EXCLUDE_DNP_OPT = "EXCLUDE DNP"
OUTPUT_NAME_OPT = "OUTPUT NAME"
OUTPUT_NAME_OPT = "OUTPUT NAME"
EXTRA_LAYERS = "EXTRA_LAYERS"
+11 -2
View File
@@ -1,10 +1,11 @@
import os
import wx
import pcbnew # type: ignore
import pcbnew # type: ignore
from .thread import ProcessThread
from .events import StatusEvent
from .options import EXCLUDE_DNP_OPT
from .options import EXCLUDE_DNP_OPT, EXTRA_LAYERS
from .config import layers
# WX GUI form that show the plugin progress
@@ -31,6 +32,11 @@ class KiCadToJLCForm(wx.Frame):
self.mExcludeDnpCheckbox = wx.CheckBox(self, label='Exclude DNP components')
self.mExcludeDnpCheckbox.SetValue(False)
self.mAdditionalLayersControl = wx.TextCtrl(self, size=wx.Size(600, 50))
self.mAdditionalLayersControl.Hint = "Additional layers"
self.mAdditionalLayersControl.AutoComplete(layers)
self.mAdditionalLayersControl.Enable()
self.mGenerateButton = wx.Button(self, label='Generate', size=wx.Size(600, 60))
self.mGaugeStatus = wx.Gauge(
@@ -44,6 +50,7 @@ class KiCadToJLCForm(wx.Frame):
boxSizer.Add(self.mOptionsLabel, 0, wx.ALL, 5)
# boxSizer.Add(self.mOptionsSeparator, 0, wx.ALL, 5)
boxSizer.Add(self.mAdditionalLayersControl, 0, wx.ALL, 5)
boxSizer.Add(self.mExcludeDnpCheckbox, 0, wx.ALL, 5)
boxSizer.Add(self.mGaugeStatus, 0, wx.ALL, 5)
boxSizer.Add(self.mGenerateButton, 0, wx.ALL, 5)
@@ -58,7 +65,9 @@ class KiCadToJLCForm(wx.Frame):
def onGenerateButtonClick(self, event):
options = dict()
options[EXCLUDE_DNP_OPT] = self.mExcludeDnpCheckbox.GetValue()
options[EXTRA_LAYERS] = self.mAdditionalLayersControl.GetValue()
self.mAdditionalLayersControl.Hide()
self.mExcludeDnpCheckbox.Hide()
self.mOptionsLabel.Hide()
self.mGenerateButton.Hide()
+10 -3
View File
@@ -42,7 +42,7 @@ class ProcessManager:
# Finally rebuild the connectivity db
self.board.BuildConnectivity()
def generate_gerber(self, temp_dir):
def generate_gerber(self, temp_dir, extra_layers):
'''Generate the Gerber files.'''
settings = self.board.GetDesignSettings()
settings.m_SolderMaskMargin = 50000
@@ -67,8 +67,13 @@ class ProcessManager:
if hasattr(plot_options, "SetExcludeEdgeLayer"):
plot_options.SetExcludeEdgeLayer(True)
if extra_layers is not None:
extra_layers = [element.strip() for element in extra_layers.strip().split(',') if element.strip()]
else:
extra_layers = []
for layer_info in plotPlan:
if self.board.IsLayerEnabled(layer_info[1]):
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])
@@ -150,7 +155,9 @@ class ProcessManager:
# 2: 'unspecified'
# }.get(footprint.GetAttributes())
skip_footprint = exclude_dnp and (footprint_has_field(footprint, 'dnp') or footprint.GetValue().upper() == 'DNP')
skip_footprint = exclude_dnp and (footprint_has_field(footprint, 'dnp')
or footprint.GetValue().upper() == 'DNP'
or getattr(footprint, 'IsDNP', bool)())
if not (footprint.GetAttributes() & pcbnew.FP_EXCLUDE_FROM_POS_FILES) and not skip_footprint:
# append unique ID if duplicate footprint designator
+1 -1
View File
@@ -39,7 +39,7 @@ class ProcessThread(Thread):
# generate gerber
self.progress(20)
self.process_manager.generate_gerber(temp_dir_gerber)
self.process_manager.generate_gerber(temp_dir_gerber, self.options[EXTRA_LAYERS])
# generate drill file
self.progress(30)