Skip to content

Commit b788dd6

Browse files
committed
Skip unwanted Cu layers
1 parent e33bdfd commit b788dd6

File tree

4 files changed

+211
-660
lines changed

4 files changed

+211
-660
lines changed

SparkFunKiCadCAMmer/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# os.path.join(dir_path, 'deps'),
1717
#]
1818

19-
def check_for_panelizer_button():
19+
def check_for_cammer_button():
2020
# From Miles McCoo's blog
2121
# https://kicad.mmccoo.com/2017/03/05/adding-your-own-command-buttons-to-the-pcbnew-gui/
2222
def find_pcbnew_window():
@@ -45,16 +45,16 @@ def callback(_):
4545
if button_wx_item_id == 0 or not top_tb.FindTool(button_wx_item_id):
4646
top_tb.AddSeparator()
4747
button_wx_item_id = wx.NewId()
48-
top_tb.AddTool(button_wx_item_id, "SparkFunKiCadPanelizer", bm,
49-
"SparkFun KiCad Panelizer", wx.ITEM_NORMAL)
48+
top_tb.AddTool(button_wx_item_id, "SparkFunKiCadCAMmer", bm,
49+
"SparkFun KiCad CAMmer", wx.ITEM_NORMAL)
5050
top_tb.Bind(wx.EVT_TOOL, callback, id=button_wx_item_id)
5151
top_tb.Realize()
5252

5353

5454
try:
5555
with add_paths(paths):
56-
from .plugin import PanelizerPlugin
57-
plugin = PanelizerPlugin()
56+
from .plugin import CAMmerPlugin
57+
plugin = CAMmerPlugin()
5858
plugin.register()
5959
except Exception as e:
6060
print(e)
@@ -65,7 +65,7 @@ def callback(_):
6565
# Add a button the hacky way if plugin button is not supported
6666
# in pcbnew, unless this is linux.
6767
if not plugin.pcbnew_icon_support and not sys.platform.startswith('linux'):
68-
t = threading.Thread(target=check_for_panelizer_button)
68+
t = threading.Thread(target=check_for_cammer_button)
6969
t.daemon = True
7070
t.start()
7171

SparkFunKiCadCAMmer/cammer/cammer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ def startCAMmer(self, args, board=None, logger=None):
7373
zipFilename = os.path.split(sourceBoardFile)[1] # Get the file path tail
7474
zipFilename = os.path.join(outputPath, os.path.splitext(zipFilename)[0] + ".zip")
7575
else: # Running in a plugin
76-
outputPath = os.path.split(board.GetFileName())[0] # Get the file path head
77-
zipFilename = os.path.split(board.GetFileName())[1] # Get the file path tail
76+
sourceBoardFile = board.GetFileName()
77+
outputPath = os.path.split(sourceBoardFile)[0] # Get the file path head
78+
zipFilename = os.path.split(sourceBoardFile)[1] # Get the file path tail
7879
zipFilename = os.path.join(outputPath, os.path.splitext(zipFilename)[0] + ".zip")
7980

8081
if board is None:
@@ -97,7 +98,6 @@ def startCAMmer(self, args, board=None, logger=None):
9798
sysExit = 1
9899
return sysExit, report
99100

100-
101101
# Build layer table
102102
layertable = {}
103103
numlayers = PCB_LAYER_ID_COUNT
@@ -228,7 +228,7 @@ def startCAMmer(self, args, board=None, logger=None):
228228

229229
mirror = False
230230
minimalHeader = False
231-
offset = VECTOR2I(0,0)
231+
offset = board.GetDesignSettings().GetAuxOrigin() # Was: offset = VECTOR2I(0,0)
232232
# False to generate 2 separate drill files (one for plated holes, one for non plated holes)
233233
# True to generate only one drill file
234234
mergeNPTH = True
@@ -238,7 +238,7 @@ def startCAMmer(self, args, board=None, logger=None):
238238
drlwriter.SetFormat( metricFmt )
239239

240240
genDrl = True
241-
genMap = True
241+
genMap = False
242242
drlwriter.CreateDrillandMapFilesSet( pctl.GetPlotDirName(), genDrl, genMap )
243243

244244
if mergeNPTH:

SparkFunKiCadCAMmer/plugin.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,21 @@ def Run(self):
7171
for i in range(numlayers):
7272
layertable[board.GetLayerName(i)] = i
7373

74+
# Check the number of copper layers. Delete unwanted layers from the table.
75+
wantedCopper = []
76+
if board.GetCopperLayerCount() >= 2:
77+
wantedCopper.extend(['F.Cu','B.Cu'])
78+
if board.GetCopperLayerCount() >= 4:
79+
wantedCopper.extend(['In1.Cu','In2.Cu'])
80+
if board.GetCopperLayerCount() >= 6:
81+
wantedCopper.extend(['In3.Cu','In4.Cu'])
82+
deleteLayers = []
83+
for layer in layertable.keys():
84+
if layer[-3:] == ".Cu":
85+
if layer not in wantedCopper:
86+
deleteLayers.append(layer)
87+
for layer in deleteLayers:
88+
layertable.pop(layer, None)
7489

7590
def run_cammer(dlg, p_cammer):
7691
self.logger.log(logging.INFO, "Running CAMmer")

0 commit comments

Comments
 (0)