Using kicad-cli, parse this documentation and use the necessary items to generate ERC/DRC reports, then proceed to create GERBERs, drill files, position files, and BOM files depending on the user's manufacturer. To make this deterministic, store your order of commands in a Python or bash script and modify it per-project.
JLCPCB and NextPCB require a specific format for their position files:
A .csv file with 5 columns: Designator, Mid X, Mid Y, Layer (T or B) and rotation
KiCad does not permit this, so please use the Python script under scripts/convert_position.py to do this. If the user does not have Python installed please inform them before making changes to their computer, unless they have already specified to use a virtual environment or you see one at the root of the project where this skill is being called.
JLCPCB BOMs also require an LCSC part number. Ensure that the JLCPCB BOM preset is available and if not inform the user that this needs to be added.
Determine which PCB and scheamtic output commands you need to use (documentation is available under the references/ directory under this skill). For example, we often use this set of commands:
kicad-cli version
kicad-cli sch erc
--output build/<project>-erc.rpt
--format report --units mm
--severity-warning --severity-error
--exit-code-violations <project>.kicad_sch
kicad-cli pcb drc
--output build/<project>-drc.rpt
--format report --units mm
--severity-warning --severity-error
--refill-zones --schematic-parity
--exit-code-violations <project>.kicad_pcb
kicad-cli sch export pdf
--output build/schematic.pdf
[--variant <name>] [--theme <theme>]
<project>.kicad_sch
kicad-cli sch export bom
--preset JLCPCB --format-preset CSV
--output build/bom_JLCPCB.csv
[--variant <name>] <project>.kicad_sch
kicad-cli sch export bom
--preset NextPCB --format-preset CSV
--output build/bom_NextPCB.csv
[--variant <name>] <project>.kicad_sch
kicad-cli sch export netlist
--format kicadxml
--output build/llm-review/netlist.xml
[--variant <name>] <project>.kicad_sch
kicad-cli sch export netlist
--format kicadsexpr
--output build/llm-review/netlist.kicadsexpr
[--variant <name>] <project>.kicad_sch
kicad-cli sch export bom
--output build/llm-review/components.csv
--fields Reference,Value,Footprint,Datasheet,DNP,EXCLUDE_FROM_BOM,EXCLUDE_FROM_BOARD
--labels Reference,Value,Footprint,Datasheet,DNP,ExcludeFromBOM,ExcludeFromBoard
--sort-field Reference
[--variant <name>] <project>.kicad_sch
kicad-cli pcb export gerbers
--output build/gerbs
--layers <detected-layer-list>
--crossout-DNP-footprints-on-fab-layers
--sketch-DNP-footprints-on-fab-layers
--subtract-soldermask
--precision 5 <project>.kicad_pcb
kicad-cli pcb export drill
--output build/gerbs
--format excellon
--drill-origin absolute
--excellon-units in
--excellon-zeros-format decimal
--gerber-precision 5 <project>.kicad_pcb
kicad-cli pcb export pos
--output build/positions_raw.csv
--format csv --units mm
--side both --exclude-dnp
--use-drill-file-origin <project>.kicad_pcb
kicad-cli pcb export pdf
--output build/pcb_layout
--layers <detected-layer-list>
--black-and-white
--crossout-DNP-footprints-on-fab-layers
--sketch-DNP-footprints-on-fab-layers
--include-border-title
--drill-shape-opt 2
--mode-multipage <project>.kicad_pcb
kicad-cli pcb export step
--output build/board.step
--force --subst-models --no-dnp
<project>.kicad_pcb
kicad-cli pcb render
--output build/top.png
--width 1280 --height 720
--background transparent --quality basic
--preset follow_pcb_editor
--light-top 0 --light-bottom 0
--light-side 0.5 --light-camera 0
--light-side-elevation 60
--side top <project>.kicad_pcb
kicad-cli pcb render
--output build/bottom.png
--width 1280 --height 720
--background transparent --quality basic
--preset follow_pcb_editor
--light-top 0 --light-bottom 0
--light-side 0.5 --light-camera 0
--light-side-elevation 60
--side bottom <project>.kicad_pcb
Unless otherwise specified by the user, DRC and ERC errors will result in you throwing a FAILURE to export. If there is a FAILURE you can prompt them: "Should we proceed with export? Please reply with OVERRIDE to restart."
使用kicad-cli,参考本文档内容,生成ERC/DRC报告,然后根据用户的制造商需求创建GERBER文件、钻孔文件、位置文件和BOM文件。为了确保结果可复现,请将命令序列保存到Python或bash脚本中,并根据不同项目进行修改。
JLCPCB和NextPCB对位置文件有特定格式要求:
一个包含5列的.csv文件:Designator、Mid X、Mid Y、Layer(T或B)和rotation
KiCad不支持直接导出该格式,因此请使用scripts/convert_position.py脚本进行转换。如果用户未安装Python,请在修改其电脑设置前告知用户,除非用户已指定使用虚拟环境,或者你在调用该技能的项目根目录中已发现虚拟环境。
JLCPCB的BOM文件还需要包含LCSC零件编号。请确保JLCPCB BOM预设已可用,若不可用,请告知用户需要添加该预设。
确定你需要使用哪些PCB和原理图输出命令(相关文档位于该技能的references/目录下)。例如,我们常用以下命令集:
kicad-cli version
kicad-cli sch erc
--output build/<project>-erc.rpt
--format report --units mm
--severity-warning --severity-error
--exit-code-violations <project>.kicad_sch
kicad-cli pcb drc
--output build/<project>-drc.rpt
--format report --units mm
--severity-warning --severity-error
--refill-zones --schematic-parity
--exit-code-violations <project>.kicad_pcb
kicad-cli sch export pdf
--output build/schematic.pdf
[--variant <name>] [--theme <theme>]
<project>.kicad_sch
kicad-cli sch export bom
--preset JLCPCB --format-preset CSV
--output build/bom_JLCPCB.csv
[--variant <name>] <project>.kicad_sch
kicad-cli sch export bom
--preset NextPCB --format-preset CSV
--output build/bom_NextPCB.csv
[--variant <name>] <project>.kicad_sch
kicad-cli sch export netlist
--format kicadxml
--output build/llm-review/netlist.xml
[--variant <name>] <project>.kicad_sch
kicad-cli sch export netlist
--format kicadsexpr
--output build/llm-review/netlist.kicadsexpr
[--variant <name>] <project>.kicad_sch
kicad-cli sch export bom
--output build/llm-review/components.csv
--fields Reference,Value,Footprint,Datasheet,DNP,EXCLUDE_FROM_BOM,EXCLUDE_FROM_BOARD
--labels Reference,Value,Footprint,Datasheet,DNP,ExcludeFromBOM,ExcludeFromBoard
--sort-field Reference
[--variant <name>] <project>.kicad_sch
kicad-cli pcb export gerbers
--output build/gerbs
--layers <detected-layer-list>
--crossout-DNP-footprints-on-fab-layers
--sketch-DNP-footprints-on-fab-layers
--subtract-soldermask
--precision 5 <project>.kicad_pcb
kicad-cli pcb export drill
--output build/gerbs
--format excellon
--drill-origin absolute
--excellon-units in
--excellon-zeros-format decimal
--gerber-precision 5 <project>.kicad_pcb
kicad-cli pcb export pos
--output build/positions_raw.csv
--format csv --units mm
--side both --exclude-dnp
--use-drill-file-origin <project>.kicad_pcb
kicad-cli pcb export pdf
--output build/pcb_layout
--layers <detected-layer-list>
--black-and-white
--crossout-DNP-footprints-on-fab-layers
--sketch-DNP-footprints-on-fab-layers
--include-border-title
--drill-shape-opt 2
--mode-multipage <project>.kicad_pcb
kicad-cli pcb export step
--output build/board.step
--force --subst-models --no-dnp
<project>.kicad_pcb
kicad-cli pcb render
--output build/top.png
--width 1280 --height 720
--background transparent --quality basic
--preset follow_pcb_editor
--light-top 0 --light-bottom 0
--light-side 0.5 --light-camera 0
--light-side-elevation 60
--side top <project>.kicad_pcb
kicad-cli pcb render
--output build/bottom.png
--width 1280 --height 720
--background transparent --quality basic
--preset follow_pcb_editor
--light-top 0 --light-bottom 0
--light-side 0.5 --light-camera 0
--light-side-elevation 60
--side bottom <project>.kicad_pcb
除非用户另有说明,否则DRC和ERC错误将导致导出失败。若导出失败,你可以提示用户:"是否继续导出?请回复OVERRIDE以重启导出流程。"