Skip to content

Commit f418066

Browse files
committed
Add support for auto naming of JLC PCB fabrication
1 parent 8c980f3 commit f418066

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

docs/fabrication/jlcpcb.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ kikit fab jlcpcb [OPTIONS] BOARD OUTPUTDIR
77

88
When you run this command, you will find file `gerbers.zip` in `OUTPUTDIR`. This
99
file can be directly uploaded to JLC PCB site. KiKit automatically detects the
10-
number of layers.
10+
number of layers. If you would like to include the project name in the archive
11+
name, you can supply `--autoname`
1112

1213
If you want to name your files differently, you can specify `--nametemplate`.
1314
This option takes a string that should contain `{}`. This string will be

kikit/fab/jlcpcb.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ def bomToCsv(bomData, filename):
5656
writer.writerow([value, ",".join(refChunk), footprint, lcsc])
5757

5858
def exportJlcpcb(board, outputdir, assembly, schematic, ignore, field,
59-
corrections, correctionpatterns, missingerror, nametemplate, drc):
59+
corrections, correctionpatterns, missingerror, nametemplate, drc,
60+
autoname):
6061
"""
6162
Prepare fabrication files for JLCPCB including their assembly service
6263
"""
@@ -74,7 +75,11 @@ def exportJlcpcb(board, outputdir, assembly, schematic, ignore, field,
7475
shutil.rmtree(gerberdir, ignore_errors=True)
7576
gerberImpl(board, gerberdir)
7677

77-
archiveName = expandNameTemplate(nametemplate, "gerbers", loadedBoard)
78+
if autoname:
79+
boardName = os.path.basename(board.replace(".kicad_pcb", ""))
80+
archiveName = expandNameTemplate(nametemplate, boardName + "-gerbers", loadedBoard)
81+
else:
82+
archiveName = expandNameTemplate(nametemplate, "gerbers", loadedBoard)
7883
shutil.make_archive(os.path.join(outputdir, archiveName), "zip", outputdir, "gerber")
7984

8085
if not assembly:

kikit/fab_ui.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def fabCommand(f):
3131
help="Comma separated list of component fields with the correction value. First existing field is used")
3232
@click.option("--correctionpatterns", type=click.Path(dir_okay=False))
3333
@click.option("--missingError/--missingWarn", help="If a non-ignored component misses LCSC field, fail")
34+
@click.option("--autoname", is_flag=True, help="Automatically name the output files based on the board name")
3435
def jlcpcb(**kwargs):
3536
"""
3637
Prepare fabrication files for JLCPCB including their assembly service

0 commit comments

Comments
 (0)