KiBot, fabrication and documentation automation

KiBot is a Python script that can be used to automate the generation of fabrication (gerbers, drill, etc.) and documentation (BoM, PDF, SVGs, 3D model, etc.) files.
In addition it can run the DRC and ERC automatically.
It can be integrated to CI/CD workflows.

General podcast

The script uses other scripts to achieve some of the functionality and supports KiCad 5, 6, 7 and 8.
Currently you can:

  • Run the ERC
  • Ensure the XML file used by KiBoM is updated
  • Generate the BoM (using KiBoM or an enhanced version of it that is part of KiBot). You can also consolidate parts from multiple projects.
  • Include components costs in the BoM using KiCost.
  • Print the schematic to a PDF, SVG, PS, DXF or HPGL.
  • Generate netlists in classic or IPC-D-356 formats.
  • Run the DRC
  • Ensure all zones are refilled.
  • Generate the gerbers (and all the other formats of the Plot menu SVG, DXF, HPGL, etc.). Including templates for Elecrow, FusionPCB, JLCPCB, P-Ban and PCBWay.
  • Generate the drill files (both excellon and gerber format supported, including the PDF maps)
  • Generate the position files (including rotation corrections and support for XYRS formats)
  • Print selected layers to a PDF/SVG/PNG/EPS/PS (what you get from the Print menu)
  • Export the 3D STEP, VRML, FBX, OBJ, X3D, GLTF, STL or PLY for the PCB
  • Create a 3D render of the PCB, using KiCad or Blender (high quality)
  • Generate images of how the PCB will look using different solder mask colors (using PcbDraw)
  • Generate an interactive mounting BoM in HTML (using InteractiveHtmlBom)
  • Export the PCB in Gencad format
  • Update KiCad 6 text variables (dates, git hashes, etc.).
  • Generate QR codes for the schematic and/or PCB.
  • Generate a report of the project, including information about minimum sizes, drill sizes, stack-up options, testpoints and images.
  • Generate compressed files (ZIP, RAR or TAR) containing selected outputs
  • Join PDFs to consolidate documents.
  • Download the datasheets (using the URLs in the datasheet field of the schematic components)
  • Download 3D models from EasyEDA.
  • Generate a Makefile allowing to execute steps incrementally (i.e. only the affected stuff is redone)
  • Generate webpages to browse the generated files, take a look at this example
  • Compute the differences between two PCBs or schematics. Also show it interactively using KiRi.
  • Collect information about the environment and tools used during the process
  • Copy the 3D models of a project to some destination, also create a PCB adapted to use the collected 3D models.
  • Generate web pages showing how to assemble the PCB (using populate tool)
  • Generate web pages to present your project.
  • Panelize the PCB (using KiKit)
  • Create stencils (both steel and 3D printed, also using KiKit)
  • Generate a PCB and/or schematic with the variants applied.
  • Generate web pages to browse the schematics and/or PCB using KiCanvas
  • Create and update stackup drawings (also the tables from KiCad)
  • Create and update tables in the PCB generated using the CSV files from the bom, kibom and position outputs

For an example visit the Spora demo repo

Implements assembly variants, allowing:

  • Mark not fitted components with a cross in the schematic
  • Mark not fitted components with a cross in the *.Fab layers of the PCB
  • Remove solder paste from not fitted components
  • Remove adhesive glue from not fitted components
  • Exclude components from the BoM (also mark them as DNF and/or DNC (Do Not Change))
  • Exclude components from the interactive BoM
  • Remove not fitted components from the STEP file
  • Exclude components from the position (pick & place) file
  • Change any field according to the variant (i.e change the component value)
  • Change the 3D model/s

Currently three mechanisms are supported to specify variants: KiBoM, KiCost and IBoM styles. But this is also implemented as plug-ins, so more styles can be added.

In additions you can separate multi-board PCBs that uses the KiKit mechanism using variants.

For more information about variants visit the demo repo

All the output files are generated by plug-ins, so the script can be enhanced without needing to know all the internal details.

Currently you can run it on Linux and on CI/CD workflows like GitHub (docker files containing KiCad and all the supporting scripts are available). Some users succeed using Windows (using WSL or docker), but the setup is more complex. Most of the outputs can be used on plain Windows, but some really needs a Linux style environment.

I’m looking for collaborators to support Windows and MacOSX.

Changes in 1.8.2

Added

  • Experimental GUI
  • Preflights:
    • Draw Fancy Stackup: which includes the type of vias used
    • Include Table: used to include CSV tables generated by bom/position
      outputs
  • Globals:
    • dnp_cross_top_layer and dnp_cross_bottom_layer: to control the layer
      where footprints are crossed.
  • SVG: use_aux_axis_as_origin option
  • Report: thickness units
  • PCB Print:
    • Worksheet: undocumented font face and color now can be used
  • Panelize:
    • copy_vias_on_mask option to workaround KiCad’s bug 18991

Fixed

  • Blender Export:
    • Stacked boards when using an automatically generated PCB3D.
    • Point of view when using the human names instead of the axis names.
  • Footprint variant (created by Var Replace filter):
    • Flipped components didn’t get flipped after replacement (#664)
    • Problems generating drill outputs (#663)
  • BoM: Sub-PCBs not applied
  • Copy Files: problems when using from compress and using worksheets.
  • Export Project: problems when downloading KiCad models and trying to compress
    the result.
  • PcbDraw: problems with 0 ohms THT resistors
  • PCB Print:
    • Errors when printing a fully empty layer
    • Allow specifying repeat_for_layer with empty repeat_layers.
      This was the old behavior (i.e. 1.7.0)
    • Problems with drill marks on KiCad 8.0.4+, which prints them in every
      single layer (even technical ones)
    • When trying to force a WKS and the project didn’t define a WKS.
      The “gui” strategy failed to use the specified WKS
  • Draw stackup:
    • Segmentation Fault on KiCad 8 when creating a new group
    • Units not applied when creating a new group
  • Expansion of internal field names. KiCad expands “VALUE”, not “Value”, which
    is what you see in the GUI

Changed

  • Quick Start:
    • Diff/KiRi: Avoid creating when we don’t have at least 2 to compare
  • PCB Print:
    • Avoid colored_pads and colored_vias side effects
  • BoM:
    • Avoid leaking DIGIKEY_CLIENT_ID and DIGIKEY_CLIENT_SECRET in logs

Changes in 1.8.0

Added

  • Experimental Altium PCB conversion
  • Most places where a field is expected now support _field_* to fetch the
    globally defined value.
  • Preflights:
    • check_fields: used to ensure conditions on desired fields
    • e/drc: option to force english messages (needed for KiCad 8.0.4)
  • Filters:
    • separate_pins: used to create testpoint reports
    • _null can be used to skip the filters processing
  • Global options:
    • use_pcb_fields: allows using fields defined in the PCB (and not
      only in the schematic), enabled by default
    • field_current: to specify the field used for current ratings
  • Internal templates:
    • Testpoints_by_attr, Testpoints_by_attr_CSV, Testpoints_by_attr_HTML,
      Testpoints_by_value, Testpoints_by_value_CSV and Testpoints_by_value_HTML:
      Used to generate testpoint reports
  • Command line:
    • Option to also list sub-PCBs found in variants
  • BoardView: support for BVR format
  • BoM: logo file name can contain env vars and/or ~
  • Datasheet: option to classify the datasheets by reference.
  • KiCost: option to specify a configuration file
  • Report:
    • Solder paste usage stats
    • Support for variants
    • Testpoints report
  • xDRC: configurable category
  • Schematic:
    • Support for text boxes inside symbols
  • Worksheet:
    • Support for KiCad 8 bitmaps
  • Position:
    • Support for panels repeating the same component

Fixed:

  • iBoM: highlight_pin1 option didn’t allow the use of the new choices.
  • PCB2Blender_Tools: transform filters might make it fail.
  • BoM:
    • No color reference when using row colors but not column or kicost colors.
    • “0 pico” for “0”
    • Use of lcsc_link as boolean
    • User fields for components that are only in the PCB not filled
  • Worksheet: Size of PNGs that specify its PPI resolution.
  • Filters:
    • Problems with filters that change fields for components that are
      only in the PCB.
    • Use of ‘_none’ filter in lists of filters and _kf()
  • Variants:
    • Problems when remove_solder_paste_for_dnp and remove_adhesive_for_dnp are both disabled (remove_solder_mask_for_dnp wrongly defined)
    • Problems when using set_text_variables_before_output
  • Draw Stackup:
    • Dimension always drawn on User.Drawings layer
    • Problems when the PCB wasn’t loaded by another preflight
  • Update XML: check_pcb_parity not usable for KiCad 8, must use the drc
    preflight
  • PCB Print: %ln and %ll substitution when using repeat_for_layer option
  • Render_3D: bottom side components that doesn’t rotate from its center got
    displaced highlight
  • QR Lib output and various preflights: might remove DRC exclusions. This is
    a KiCad bug that we must workaround
  • 3D outputs: temporal .kicad_dru file not removed
  • Generated PCB files: problems with some big structures, like zone fills,
    that could generate huge lines in the generated PCB, not supported by KiCad.

Changed:

  • KiCad 8.0.2: The behavior with hidden text changed in KiCad 8.0.2, it is
    computed even for operations where it isn’t really visible, like plotting
    a layer where we don’t have the hidden text. So currently KiBot is
    experimentally disabling the “hidden text layer”.
    This is a bug in KiCad ([8.0.2] Plot bounding box affected by invisible text (hidden text GAL) (#17958) ¡ Issues ¡ KiCad / KiCad Source Code / kicad ¡ GitLab)
  • Render 3D: Modern versions of Image Magick no longer needs two trim passes
    for auto-crop, so now we default to one and an option enables two.
  • Preflights: The definition of preflight plug-ins changed. They are slightly
    different now. Currently they are Optionable and share more in common with
    outputs. If you need assistance to migrate a preflight just open a GitHub
    issue.
  • Outputs: Now all options must declare its default.
  • Global invalidate_pcb_text_cache: now it changes the PCB on disk, not just
    on memory. This is needed for external tools like KiKit’s panelize.
  • In many cases now we allow empty lists and use some sort of default.
    A warning is issued, but we continue.
    • Layers: now the default for missing layers is all layers.
    • Copy files: Now we don’t stop when nothing to copy is specified
    • Layers: now the default for missing layers is all layers.
    • KiKit Present: Missing description is no longer fatal
    • Any PCB Print/PCB Print: Missing pages/layers is no longer fatal
    • Populate: Missing input file is no longer fatal
    • QR Lib: Missing QR definition is no longer fatal (%p %r used)
    • Blender Options outputs: Make a render when no outputs are specified
    • PCB Print: repeat_layers defaults to inners
    • Spec to Field: some simple defaults for the specs (voltage, current, power
      and tolerance)
7 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.