KiField saved me a ton of manual KiCad editing

I am still using KiCad 5.1 because I cannot risk having version 6 change my custom libraries (I have a lot) since I am still involved in a large, to me, project, which, for privacy I will simply refer to as the “project”. It isn’t “my” project – I am consulting on it. I have entered the point of selecting a fabricator that will make the board AND assemble the boards – just a few at first for functional testing. I’ve had problems finding a suitable USA fabricator – the two that I have existing accounts with seem to have vaporized with marginally functional websites and no response to my queries. Possibly the COVID shutdown killed, or nearly killed their businesses.

Years ago I had Seeed make some boards but not assembly, although they do offer assembly. Those boards were nicely made. I decided to price a different Chinese fabricator. While they had no problem with my uploaded design files the BOM is another story. While reformatting KiCad’s BOM output to match what Pcbway wants isn’t a big deal, I wanted to use LCSC parts for the resistors, capacitors, coils, etc. and few select ICs. I “may” have to ship them a few specialized ICs for assembly. The problem is that I needed the LCSC part numbers for about eighty parts. I REALLY didn’t want to have to hand edit eighty parts using eschema.

I searched around and found just the tool that I needed to semi-automatically update all of the parts in my KiCad project’s eschema sch file. It is Dave Vandenbout’s “KiField”. I won’t explain the details, for that see the documentation in Dave’s github at https://github.com/devbisme/KiField or at https://kifield.readthedocs.io/en/latest/usage.html. The synopsis is that KiField is a utility for manipulating part fields in KiCad schematic files or libraries. KiField can extract all the component fields from a schematic or library and place them into a spreadsheet for bulk editing, after which you can insert the edited values from the spreadsheet back into the schematic or library.

Here is what I did.
– I uploaded the project’s BOM to LCSC’s website BOMtool at lcsc.com. This creates a spreadsheet-like page(s) which as every part along with the LCSC part number. This can be downloaded as a csv file, which I did. Oddly, LCSC doesn’t show the part designation/Reference unless to name that column “description” before uploading the BOM.
– Next I used KiField to download all of the parts to a new “extracted” cvs spreadsheet file using this syntax: kifield -x ..//project.sch -i project-extracted-fields.csv
– Next, after making sure that the sort was identical, I copied the “lcsc part number” column from the downloaded LCSC spreadsheet to a new LCSC_PN column in project-extracted-fields.csv (open in spreadsheet program first, of course).
– The final step was to populate the project’s appropriate 80 parts with the LCSC part numbers with the following command: kifield -i ..//project.sch -x project-extracted-fields.csv -w

That’s it. KiField saved me a ton of manual work. Thank you Dave Vandenbout!

Update – Using Kifield with KiCad v6.0.6

I have migrated an old project from KiCad v5.1 to v6.0.6. I needed to change some of the hidden fields but it didn’t go well with KiField. Unlike when using KiField with KiCad v5.1, every new field or field entry would be marked “visible” and the schematic became quite cluttered.

The KiField documentation states:

To manage the visual clutter of a schematic, you can set the visibility or invisibility of inserted fields as follows:

Prefixing the header of a column with [I] will make every entry in that column invisible. Prefix with a [V] to make them all visible.

Any values in the column prefixed with [I] or [V] will override the column heading.

Without prefixes, any new field is invisible by default.

Existing fields retain whatever their original visibility/invisibility was.

I did not understand this instruction and thought that the brackets were just for emphasis in the instructions. No, you must use the brackets!

If a new spreadsheet field column or just a new item in an existing field column is edited into the spreadsheet that is to be inserted into the .kicad_sch file then the [I] must be explicitly added as a prefix. Otherwise, the default is visible.

As an example, if a new column named WIDGET is added to the spreadsheet and you don’t want it to be visible on the eeschema schematic displayed, then the spreadsheet column must be named [I]WIDGET

The “[I]” is an instruction for KiField and it won’t appear in the schematic – only WIDGET.

All of this is also true if you add a new entry into an existing field column. So, for example, a new entry into existing a column named MPN would require that the existing column be renamed [I]MPN IF you want all in MPN to be invisible.

This entry was posted in Electronics, Linux, PCB Design and tagged . Bookmark the permalink.

Leave a comment