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, 8 and 9.
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 OrcadPCB2, Allegro, CADSTAR, PADS, KiCad XML, Spice and Spice model 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, XAO, BREP, GLB 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, ODB++ or IPC-2581 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
  • Run KiCad 9 jobsets

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.3

Added

  • New outputs:

    • ODB: Exports the PCB in ODB++ format (KiCad 9)
    • IPC2581: Exports the PCB in IPC-2581 (IPC-DPMX) format (KiCad 9)
    • export_3d: Exports the 3D model of the PCB in BREP, GLB, STL, STEP and XAO (KiCad 9)
    • jobset: Runs a KiCad jobset (KiCad 9)
  • CLI:

    • --variant to specify which variants will be generated
    • --defs-from-project allows using KiCad variables for the preprocessor
  • Variants and filters:

    • Outputs with variants can now specify an exclude_filter in addition to the variant. Like it was possible for transform and dnf
  • Preflights:

    • consolidate_pcbs: Used to merge PCBs before creating 3D stacked renders
    • expand_in_command option to set_text_variables, used to expand %X patterns in the command
    • check_fields mechanism to check for extra fields
  • Global options:

    • work_layer: to choose the temporal layer for internal operations
  • Internal templates:

    • _KIBOT_DRILL_AUX_ORIGIN option to control drill, position and gerber origin
  • Workaround for people using backslashes (i.e. Windows+WSL) More general than in previous versions.

  • Blender Export: option to avoid soldering heatsinks

  • Boardview: OBDATA support

  • BoM:

    • Field aliases ${QUANTITY} and ${ITEM_NUMBER} for compatibility with
      KiCad’s internal BoM.
    • Fields ${DNP}, ${EXCLUDE_FROM_BOARD} and ${EXCLUDE_FROM_SIM}, like the ones used by KiCad’s internal BoM.
    • Using _kicad_bom_fields in the list of columns now you can import the fields from the KiCad’s internal BoM.
    • New option group_not_fitted to group not fitted components with fitted components. For compatibility with KiCad’s internal BoM.
    • New option sort_ascending to sort in reverse order
    • New sort style: kicad_bom, uses the field an ascending used by KiCad’s BoM
    • ref_range_separator option to configure the character used for reference ranges
    • use_ref_ranges alias for use_alt
    • New kicad format to mimic KiCad’s internal BoM.
    • right_digits option to control the decimals for position fields
    • New sort_style named field and sort_field option to sort by one or more arbitrary fields.
    • New csv options: (to match KiCad internal BoM functionality)
      • string_delimiter to configure the quote character
      • keep_line_breaks to remove line breaks in fields
      • keep_tabs to remove tabs in fields
  • Draw Fancy Stackup:

    • border_thickness: Thickness of the borders of stackup drawing and stackup table
    • A mechanism to set the font, using a text box
  • Drill:

    • Option to don’t generate the drill files, so you can generate only the maps
    • Option to generate a drill table
  • Include table:

    • A mechanism to set the font, using a text box
    • force_font_width to force a font width
  • Navigate Results:

    • New flavor “navigate_results_rb” with a “reactive” look
  • Netlist:

    • OrcadPCB2, Allegro, CADSTAR, PADS, KiCad XML, Spice and Spice model formats
  • PCB Print:

    • A mechanism to filter components for a particular layer
    • Workaround for Ghostscript handling %d wrong when followed by an hex digit
    • Now you can include drill maps using drill_pairs as repeat_layers
  • Report:

    • top_total, bot_total, total_smd, total_tht and total_all component counts
    • Also versions of the counters for excluded (exc), not fitted (dnp) and not changed (dnc)
    • total_components template, intended to generate CSV files with component counts
    • Now you can use expressions like ${V1+V2}
    • mm_digits, mils_digits and in_digits to change the number of digits for unit conversions
    • display_trailing_zeros to show trailing zeros
    • _cap sufix to capitalize strings
    • h2h, c2h and c2e Hole to Hole, Hole to Copper and Copper to Edge info (KiCad 6+)
    • pad_drill_pth, pad_drill_npth (and similars) for PTH/NPTH specific drill dimensions
    • csv_remove_leading_spaces to remove leading spaces/tabs after CSV separator (useful to generate CSV from a .txt template where elements are aligned for easier reading)
    • A mechanism to get the names of the files generated by an output. The variables are named OUTPUT_outpath_INDEX
  • SCH Variant and *SCH Print:

    • A mechanism to paste images from outputs
  • *SCH Print:

    • Default font for KiCad 9

Fixed

  • Definitions: avoid interpreting empty definitions as the “None” string
  • Guess for 3rd party dir: not just for v6
  • SubParts filter:
    • iBoM and Schematic print didn’t take it into account
    • Any output filtering by reference ignored them
  • BoM
    • The field name Reference was accepted, but didn’t work
    • Missing footprint information for sub-units
    • XLSX logo scale
  • Do Not Fit footprint crosses:
    • Problems with footprints where the center isn’t the geometric center
  • DRC:
    • Zone refill issues with the new DRC preflight
  • Draw Fancy Stackup:
    • Problems drawing micro vias
    • Confusing drawing when symmetric vias overlap
  • Drill:
    • Via pairs overwritten by PTH files
  • Navigate Results:
    • Problems when using erc: true or drc: true
  • PCB Print:
    • Problems when using the default worksheet and the internal frame plotter
    • Some layer options (use_for_center, sketch_pads_on_fab_layers and exclude_filter) not copied on repeated layers
    • sketch_pads_on_fab_layers not inherited from parent when using layer names

Changed

  • Default temporal layer for internal use is now “Margin”, instead of “User.9”
  • Draw Fancy Stackup:
    • Micro vias to look closer to real world, they only span 2 layers and they must be stacked to span more layers.
  • Renderers:
    • Components marked by the exclude filter, or marked virtual, were excluded from the 3D models and solder paste processing, but the docs says this is just for BoM

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
7 Likes

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