automation of pcb import data

I have developed a Ruby script to import an IPC-D-356 net-list file to add drill hole locations & net-name labels to a layout created by reading Gerber files via File>Import >Gerber PCB>New Project - Free Layer Mapping

This resolves the issue of attempting to read the 'Drill Files' without any way of setting the data format :(
Adds the net names to match the source PCB design :)

Is there any way of calling input() and connect() to create the 'technology' on the fly instead of having to pre-define the technology before the input process?


  • edited June 2021

    @davidnhutch Thanks - but ideally there was a kind of standard for drill files without need for setting the data format. Any idea?

    You can actually code the netlist generation directly without a technology. The key to this feature is the "LayoutToNetlist" class. Here is some sample code taken from the tests. I hope it's comprehensible. It uses two metal layers + one via and reads labels from both metal layers for net names:

        ly = RBA::Layout::new
        ... read or create layout ...
        l2n = RBA::LayoutToNetlist::new(RBA::RecursiveShapeIterator::new(ly, ly.top_cell, []))
        # only plain backend connectivity
        rmetal1     = l2n.make_polygon_layer( ly.layer(6, 0), "metal1" )
        rmetal1_lbl = l2n.make_text_layer(    ly.layer(6, 1), "metal1_lbl" )
        rvia1       = l2n.make_polygon_layer( ly.layer(7, 0), "via1" )
        rmetal2     = l2n.make_polygon_layer( ly.layer(8, 0), "metal2" )
        rmetal2_lbl = l2n.make_text_layer(    ly.layer(8, 1), "metal2_lbl" )
        # Intra-layer
        # Inter-layer
        l2n.connect(rmetal1,    rvia1)
        l2n.connect(rvia1,      rmetal2)
        l2n.connect(rmetal1,    rmetal1_lbl)   #  attaches labels
        l2n.connect(rmetal2,    rmetal2_lbl)   #  attaches labels
        # Performs netlist extraction 
        # writes the netlist database


  • Matthias,
    Thanks for the sample code, I implemented it over the weekend,
    but found the tool became unstable when attempting to use Tools>Net Browser after running it :(

    I reverted back to the original code & will use the technology files for the connectivity :)

    My client/customer is very pleased with the functionality provided with KLayout,
    this will allow them to no longer require an expensive Siemens EDA/Mentor Graphics/Valor NPI license...

  • @davidnhutch What do you mean by "unstable"? I'm a bit worried - that should not happen.

    What's the version and OS you're using? And maybe you can share some sample code which allows reproducing the problem?


  • I'm running Windows 8.1 Version 6.3 (Build 9600) 64bit on a laptop with i7-4710HQ cpu + 32Gb ram
    Can I upload and/or send you a zip file with the sample data & script?

  • I sent an email yesterday containing a zip file with the gerber files, ipc netlist, script & process flow to allow you to hopefully duplicate the issue...

  • @DavidJHutchins Thanks for the test case! See my reply and here:



  • I just sent you an email with new test-case data, I can not get the connectivity generated correctly using
    the ruby code included in the email & I do not know how to debug the data saved in the .l2n file

  • I corrected my code per your feedback & the connectivity is now correct
    Thanks for your assistance...

Sign In or Register to comment.