PCB Isolation Routing Software

Convert Kicad PCB files into GCode with isolated PCB Nets

Public Chat
Similar projects worth following
KICAD PCB software produces tracks geared towards printing. Milling the resulting tracks is neat but wasteful. This software creates a path equidistant from nearby tracks. This is done using Voronoi line segmentation.

Each track is colorized and dilated. Track dilations continue until they meet. The resulting edge between the two dilations is the isolation contour path. The contour path is then converted to Gcode. Appended to the final Gcode are drill holes, which maintain original sizes.

The software process Kicad 5.2 PCB files into gcode.

Usage more on Github site -

Usage: kicadcontour <options> <filename>

filename :- kicad pcb output file.kicad_pcb

  • -m (don't do conversion to raster but use map.png directly)
  • -f  process front layer of PCB (defaults to Bottom Layer processing)
  • -p (change pxmm scale conversion)

Files Created

  • map.png - Vector to raster conversion
  • cpp_image.png - wall paper art of your PCB
  • trace.png - Edge detection image
  • kic.gcode - Final Gcode

Vector to Raster conversion

Raster to conversion is done using  pxmm scale (pixels per mm). The resulting image map.png is then processed to create the isolation routing paths. pxmm default is set to 30. The scale is modifiable, however smaller pxmm reduces precision of paths created, whereas larger pxmm increases time to process.

Gcode Creation

The paths are converted to gcode using a path following algorithm in OpenCV.  Gcode is scaled back to original dimensions. Drill holes are appended to the gcode, using the original scale.


OpenCV contour following does not always make close contours. However, the gaps (at a pxmm of 30) are very small (in the region of 0.05-0.08mm). The tool width is larger than that, so it should not pose any problems. However, please comment on improvements.

OpenCV contour following also creates some small artefacts. However, these are not visible, but might have a minor impact on milling times.


I always optimize gcode before milling. This reduces unwanted travel time. I usually use

  • More Mods and bug fixes

    Michael Schembri08/12/2021 at 14:19 0 comments

    New Mods

    1. Increased separation now includes option for a mid-track which would result in cleaner etches.

    2. Feedrate can be overridden in gcode

    3. Holes can now be marked with a '+'. This helps centering of the drill.

    Bug fixes

    Pruned offshoot tracks created by findContour function in OpenCV. Now tracks are confined to board

  • VIA/PAD issues

    Michael Schembri01/14/2021 at 10:09 0 comments

    Noticed some issues with GCODE - VIA and PADs do not finish with a M05. This can lead to some laser cutters to omit cutting of some polygons. Amended but need to test it out.

  • More Isolation: Part 2

    Michael Schembri12/25/2020 at 18:27 1 comment

    After mod to separate zones more and mark vias. This is primary result

    Zone separation is too much, you cannot differentiate between separation and actual tracks : will reduce it.

    Vias are marked with double circle: however as shown above double marking can result in touching etch-path. Will make a different type of mark.

  • More Isolation -

    Michael Schembri11/30/2020 at 19:52 0 comments

    Problem with the output is that the tracks are very narrow. When soldering or working with the PCB, any metal debris or mis-soldering causes short-circuits.  The etched away tracks are so small that you need magnifying glasses to troubleshoot. Very time consuming.

    So, since the gcode created, runs over the same tracks twice. I could make each run shifted from the adjacent run. Now the etched tracks are larger.

    At 30pixels per mm setting the track seperation is circa 0.5mm.

    Will update on real etched PCB.

  • Small Partition issue solved

    Michael Schembri09/13/2020 at 11:09 0 comments

    Small partitions were left out of final gcode. Issue solved, however small artifacts remain as a result.

  • Ammending

    Michael Schembri09/01/2020 at 20:04 0 comments

    Update 1: Front and Bottom Layers are shifted and rotated accordingly. So they are always facing PCB side up.

    Update 2: output gcode is now into appropriate filenames "front.gcode" and "bottom.gcode".

    Update 3: Program cleans up after exit, unless you tell it to.

    Update 4: Included "makefile". Now all you need is to type in 


    in the directory.

  • Parallelizing Operation

    Michael Schembri08/17/2020 at 08:30 0 comments

    Tried parallelizing the dilation operation (the one which causes most delay), this weekend.

    Using openmp on loops. But have no control on area segmentation.

    #pragma parallel omp

    Tried segmenting the area in four. Although, I get the same track results, the background is not filled up entirely. Need to investigate more.

  • Oval Holes

    Michael Schembri08/12/2020 at 13:22 0 comments

    Now holes can be  oval inside gcode.

  • Pad rotation

    Michael Schembri08/11/2020 at 12:34 0 comments

    Rotated pads and rotated footprints corrected.

  • Edge Cuts Handling

    Michael Schembri08/10/2020 at 20:58 0 comments

    Added handling of PCB with non-rectangular edge. i.e. it will handle edged cuts (polygon and circle).

    TODO: Edge Cuts (arcs)

View all 10 project logs

Enjoy this project?



Paul McClay wrote 08/14/2021 at 17:12 point

This looks great and I expect to try it soon.

I'm a little confused. One of the logs here and mostly the repo indicate that you use this with a laser cutter. ?. Are you ablating a resist layer for etching? Does that save you a lot of laser time?

  Are you sure? yes | no

Michael Schembri wrote 08/15/2021 at 06:47 point

I laser a layer of acrylic spray used as an etch resist.

Mathematically the lines tracks should be shorter than if laser paths round every single track. Important to optimize gcode afterwards. I am trying to find a way to make the region polygons made up of straighter lines.

The problem with describing a path round each track, is that very close tracks would end up in a path overlapping. Had an initial problem with one board. So this method reduces two close laser paths into one.

Problem with this laser isolation etching is that the isolation has a very narrow width. Thus, there is a higher probability of short-circuiting two close regions.

  Are you sure? yes | no

Paul McClay wrote 08/16/2021 at 03:33 point

Ah. I had casually assumed that a sufficiently capable laser would raster out an arbitrary PCB image well enough to not bother with trying anything different. But once again realty differs. Thanks for explaining.

  Are you sure? yes | no


[this comment has been deleted]

Michael Schembri wrote 08/15/2021 at 06:41 point

Go ahead. No problem.

  Are you sure? yes | no

Twisted Pair in my Hair wrote 08/12/2020 at 08:38 point

I've been doing exactly the same thing with Voronoi algorithm couple of years ago. Then abandoned all attempts to complete it. So cool that someone did it properly!

  Are you sure? yes | no

Michael Schembri wrote 08/12/2020 at 13:23 point

Lockdown project :)

  Are you sure? yes | no

Twisted Pair in my Hair wrote 08/12/2020 at 21:33 point

It's all about isolation :)

  Are you sure? yes | no

Ken Yap wrote 08/01/2020 at 09:00 point

Nice, that's a very logical thing to do for milling.

I wonder if the algorithm could be used for boards destined for etching to create blobby tracks like from the early days of hand drawn PCB patterns.

  Are you sure? yes | no

Michael Schembri wrote 08/10/2020 at 21:01 point

Hehe :) 

Can't imagine why would one do that with kicad?

  Are you sure? yes | no

Ken Yap wrote 08/10/2020 at 22:16 point

Just for old times sake. :)

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates