Skip to content

buganini/Kikakuka

Repository files navigation

KiCad Workspace / Panelizer / Build Variants / Differ

Logo

Kikakuka (企画課, きかくか, Planning Section) (formerly Kikit-UI) is mainly built on top of KiKit, Shapely, modified pcb-tools, OpenCV, pypdfium2 and PUI.

It creates a few more dimensions for KiCad:

  • Projects
  • Revisions
  • Build Variants
  • Panelization

Features

  • Workspace Manager
    • Easily navigate between projects
      • Automatically open multiple KiCad instances on macOS
    • Recall windows of previously opened files (macOS and Windows only)
  • Differ
  • (Not just a) Panelizer
    • Interactive arrangement with real-time preview
    • Freeform placement not limited to M×N grid configurations
    • Support for multiple different PCBs in a single panel
    • Automatic or manual tab creation
    • Automatic V-cut/mousebites selection
    • Enable hole creation in panel substrate for extruded parts
    • No coding skills required
  • Build Variants (as a usage of the Panelizer)
    • Single PCB without panelization can be done with frameless setting
    • Each PCB can have its own flag settings
  • Gerber handling (experimental)
    • In panelizer context
    • Or direct conversion to .kicad_pcb
    • Allow attaching BOM/CPL (converted to reference-only footprints)
  • CLI
    • Convert saved .kkkk_pnl to kicad files in one command
    • Same usage for panelizer & build variants

Workspace Manager

The .kkkk file saves workspace information in JSON format. Workspace Manager

Differ

Schematics Differ

Schematics Differ

PCB Differ

PCB Differ

Build Variants

Set BUILDEXPR in footprints' properties. This can be done quickly with Symbol Fields Table using the current sheet only scope. Remember to sync them to PCB afterward.

BUILDEXPR-Prop

  • Kikakuka extracts build flags from BUILDEXPR. Selected flags are interpreted as true, and vice versa.
  • Footprints with the BUILDEXPR evaluated as false will be marked as DNP.
  • Footprints with unset or empty BUILDEXPR will be kept as is.

BUILDEXPR-Flags

BUILDEXPR

A boolean expression with operators:

  • ~ Not
  • & And
  • | Or

It can be as simple as a build name as shown in the image above or an expression like (A | ~B) & C.

Panelization with different build variants BUILDEXPR-Flags

Single PCB without panelization can be done with frameless setting BUILDEXPR-SinglePCB

Field Values Variants

Field#Flag will set Field to the value where flags match build flags. Multiple flags like Field#FlagA#FlagB (order insensitive) is also a supported usage. Variants-FieldValue

Panelizer

The .kikit_pnl file saves panelization settings in JSON format, with PCB paths stored relative to the file's location.

Global Alignment

Global Alignment

Per-PCB Alignment

Per-PCB Alignment

Substrate Hole

Substrate Hole

Tight Frame + Auto Tab + V-Cuts or Mousebites

UI

Output

Output

3D Output

3D Output

Tight Frame + Auto Tab + V-Cuts and Mousebites

UI

Loose Frame + Auto Tab + Mousebites

UI

3D Output

3D Output

Auto Tab

Tab position candidates are determined by the PCB edge and max_tab_spacing, prioritized by divided edge length (smaller first), and skipped if there is a nearby candidate (distance < max_tab_spacing/3) with higher priority.

In the image below with debug mode on, small red dots are tab position candidates, larger red circles are selected candidates, and the two rectangles represent the two half-bridge tabs. Auto Tab

Manual Tab

Auto tab is off for PCB with manual tabs. Drag inside the PCB for moving selected tab, drag outside the PCB for changing the direction for the selected tab. Manual Tab

Run from source (Linux/macOS)

Make sure your python can import pcbnew

> python3 -c "import pcbnew; print(pcbnew._pcbnew)"
<module '_pcbnew' from '/usr/lib/python3/dist-packages/_pcbnew.so'>

On macOS, I have to use the python interpreter bundled with KiCAD

PYTHON=/Applications/KiCad/KiCad.app/Contents/Frameworks/Python.framework/Versions/Current/bin/python3

On Linux, you should be able to just use the your default python3

PYTHON=python3

Create a virtual environment and install dependencies

${PYTHON} -m venv --system-site-packages env
./env/bin/pip3 install -r requirements.txt

Update submodule

git submodule update --init --recursive

Run

./env/bin/python3 kikakuka.py

Run from source (Windows)

On Windows the Python interpreter is at C:\Program Files\KiCad\9.0\bin\python.exe. But however in my Windows environment venv is not working properly, here is how I run it with everything installed in the KiCad's environment.

"C:\Program Files\KiCad\9.0\bin\python.exe" -m pip install -r requirements.txt
"C:\Program Files\KiCad\9.0\bin\python.exe" kikakuka.py

CLI Usage

# Just open it
./env/bin/python3 kikakuka.py

# Start with PCB files
./env/bin/python3 kikakuka.py a.kicad_pcb b.kicad_pcb...

# Load file (.kkkk or .kikit_pnl)
./env/bin/python3 kikakuka.py a.kikit_pnl

# Headless export for panelization or build variants
./env/bin/python3 kikakuka.py a.kikit_pnl out.kicad_pcb

# Differ
./env/bin/python3 kikakuka.py --differ a.kicad_sch b.kicad_sch

# Gerber to KiCAD Conversion
./env/bin/python3 kikakuka.py gerber.gbr out.kicad_pcb
./env/bin/python3 kikakuka.py gerber_folder out.kicad_pcb # BOM/CPL will be detected if they are in the folder
./env/bin/python3 kikakuka.py gerber.zip out.kicad_pcb
./env/bin/python3 kikakuka.py gerber.zip out.kicad_pcb bom_or_cpl_1.csv bom_or_cpl_2.csv # BOM/CPL files are determined by filename regardless of argument order

Reverse-Engineering Notes for KiCAD Gerber

  • Convert Gerber to .kicad_pcb with BOM/CPL using Kikakuka
  • Footprint names are also exported, so Tools -> Update Footprints from Library can bring back the footprint if the name matches
  • Lock the footprint, clean up with quick selection and deletion, unlock the footprint (you will need to set the Selection Filter)
  • If footprint update fails, focus on the User.Drawings layer and set Selection Filter to Footprints-only can help you select individual footprints and then Change Footprint

About

KiCad Workspace / Panelizer / Build Variants / Differ

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages