How to initialize your KiCAD 6 project on the command line
For the KiCAD 5 version of this script see How to initialize your KiCAD 5 project on the command line
TL;DR:
Inside the directory where you want to create the project, run
example.sh
wget -qO- https://techoverflow.net/scripts/kicad6-init.sh | bash /dev/stdin MyProject
You should replace MyProject
(at the end of the command) with your project name.
*Note:*This will initialize an empty KiCAD project without any libraries. This is equivalent to creating a new project in KiCAD itself (using the GUI).
How it works
Our script is a simple bash
script that creates the files that KiCAD creates when manually creating a new project.
It will create these files (MyProject
is the default project name, but you can modify it using a command line argument):
MyProject.pro
: The project fileMyProject.kicad_sch
: The empty schematicMyProject.kicad_pcb
: The empty PCBsym-lib-table
: List of schematic symbol libraries for the projectlibraries/MyProject.kicad_sym
: Schematic symbol libraryfp-lib-table
: List of footprint libraries for the projectlibraries/footprints
: The folder where project-specific footprints (.kicad_mod
files) are storedlibraries/3D
: This folder should be used to store 3D models (e.g. STEP files)
The files are modelled after KiCAD 5.1.4 but we expect them to work with any recent KiCAD version.
example.sh
#!/bin/bash
# TechOverflow KiCAD project initializer (with project FP & SYM libraries)
# Usage: $0 <filename prefix>
if [ $# -ne 1 ]
then
echo "Usage: $0 <filename prefix>"
exit 1
fi
# Compute project name and path
proj=$(basename "$1")
dir=$(dirname "$1")
# Create project file
cat <<EOT > ${1}.pro
update=22/05/2015 07:44:53
version=1
last_client=kicad
[general]
version=1
RootSch=
BoardNm=
[pcbnew]
version=1
LastNetListRead=
UseCmpFile=1
PadDrill=0.600000000000
PadDrillOvalY=0.600000000000
PadSizeH=1.500000000000
PadSizeV=1.500000000000
PcbTextSizeV=1.500000000000
PcbTextSizeH=1.500000000000
PcbTextThickness=0.300000000000
ModuleTextSizeV=1.000000000000
ModuleTextSizeH=1.000000000000
ModuleTextSizeThickness=0.150000000000
SolderMaskClearance=0.000000000000
SolderMaskMinWidth=0.000000000000
DrawSegmentWidth=0.200000000000
BoardOutlineThickness=0.100000000000
ModuleOutlineThickness=0.150000000000
[cvpcb]
version=1
NetIExt=net
[eeschema]
version=1
LibDir=
[eeschema/libraries]
EOT
# Create schematic file
cat <<EOT > ${1}.kicad_sch
(kicad_sch (version 20211123) (generator eeschema)
(uuid df87b081-37a2-452c-8581-7eff2c408a17)
(paper "A4")
(lib_symbols
)
(sheet_instances
(path "/" (page "1"))
)
)
EOT
cat <<EOT > ${1}.kicad_pcb
(kicad_pcb (version 4) (host kicad "dummy file") )
EOT
#
# Create schematic symbol library mapping
#
mkdir -p ${dir}/libraries
cat <<EOT > ${dir}/sym-lib-table
(sym_lib_table
(lib (name "${proj}")(type "KiCad")(uri "\${KIPRJMOD}/libraries/${proj}.kicad_sym")(options "")(descr ""))
)
EOT
cat <<EOT > ${dir}/libraries/${proj}.kicad_sym
(kicad_symbol_lib (version 20211014) (generator kicad_converter))
EOT
#
# Create footprint library mapping (just an empty directory)
#
mkdir -p ${dir}/libraries/footprints
cat <<EOT > ${dir}/fp-lib-table
(fp_lib_table
(lib (name ${proj})(type KiCad)(uri \${KIPRJMOD}/libraries/footprints)(options "")(descr ""))
)
EOT
#
# Create directory for 3D models.
# The search path might need to be configured manually
# since it's not stored in a project
#
mkdir -p ${dir}/libraries/3D
#
# Create .gitignore
#
cat <<EOT > .gitignore
*-bak
*-backups
*-cache*
*-bak*
_autosave*
\#auto_saved_files\#
EOT
Run e.g. using
example.sh
bash kicad6-init.sh MyProject
Check out similar posts by category:
Electronics, KiCAD, Shell
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow