Some scripts for helping with library development
Python Shell
Latest commit 05cbd96 Jan 15, 2017 @SchrodingersGat SchrodingersGat committed on GitHub Merge pull request #76 from jkriege2/bugfix_pcb_fix
BUGFIX: --fix of rule 6.6 did not work properly (write out nanometer-sizes!)

README.md

KiCad utilities

schlib directory

schlib.py: A python class to parse Schematic Libraries Files Format of the KiCad.

checklib.py: Such script invokes each checkrule script testing the requested libraries.

checkrule3_x.py: Each checkrule script checks your correspondent rule and prints out a report informing what is in disagreement with the KiCad Library Convention.

fix-pins.py: Such script was created in order to help the adaptation of the already existing library files to the KiCad Library Convention. It tests some cases of x/y "wrong" pins positions and try to fix them if they pass in the checking of some prerequisites. The description of the cases are explained in the head of the script file.

test_schlib.sh: A shell script used to validate the generation of files of the schlib class.

move_part.py: Script to move components between libraries.

autogen/stm32: Automatic STM32 library generation from pin files provided by ST. Detailed information can be found in autogen/stm32/README.md

sch directory

sch.py: A python class to parse Schematic Files Format of the KiCad.

test_sch.sh: A shell script used to validate the generation of files of the sch class.

add_part_number.py: This script is used to add/edit part numbers fields in the schematic files.

update_footprints.py: This script updates the footprints fields of sch files using a csv as input.

pcb directory

kicad_mod.py: A python class to handle KiCad footprint files, as know as kicad_mod.

check_kicad_mod.py: Such script invokes each checkrule script testing the requested module file.

checkruleX_Y.py: Each checkrule script checks your correspondent rule and prints out a report informing what is in disagreement with the KiCad Library Convention.

How to use

Schematic Library Checker

# first get into schlib directory
cd schlib

# run the script passing the files to be checked
./checklib.py path_to_lib1 path_to_lib2

# to check a specific component you can use the -c flag
./checklib.py -c component_name path_to_lib1

# run the following command to see other options
./checklib.py -h

Adding Part Number (PN) to Schematic Files

# first get into sch directory
cd sch

# use the following command to add empty "MPN" fields in the schematic files
./add_part_number.py path_to_sch1 path_to_sch2

# use the following command to add/edit the PN field using the passed csv file
# the default behaviour is search for "Reference(s)" and "MPN" columns in the csv
# the BOM generated by bom_csv_grouped_by_value plugin can be used after
# manually add the MPN field in the Collated Components section (for example)
./add_part_number.py --bom-csv=path_to_bom_csv path_to_sch_files/*.sch

# run the following command to see other options
./add_part_number.py -h

Footprint Checker (wip)

# first get into pcb directory
cd pcb

# run the script passing the files to be checked
./check_kicad_mod.py path_to_fp1 path_to_fp2

# run the following command to see other options
./check_kicad_mod.py -h

Notice

The scripts use a different algorithm to generate files in relation to the KiCad saving action. That will result output files with more modified lines than expected, because the line generally are repositioned. However, the file still functional.

Always check the generated files by opening them on KiCad. Additionally, if you are working over a git repository (if not, you should) you can commit your work before proceed with the scripts, this will put you safe of any trouble. Also, you would use git diff to give a look at the modifications.