Netlist to wire list?

Hi all,
As i use Kicad often i used it to create a schematic for a device that i have to wire up.
Now the problem is that if i have to wire according to the schematic. A friend of mine is helping and he has no experience with this.

To get this done faster it would be nice to be able to generate a list like:
device1p1 to R1
R1 to device4p3

something like a csv output. very basic.
Now basicly this is what a netlist is so i should be able to convert this to a csv using a plugin or something right?

This would save time if you have to wire up something because you dont need to think about it.
Maybe something allready exist.

Here is a sample netlist plugin in Python. It uses kicad_netlist_reader.py which comes with KiCad. If you know Python, it should be easy to generate any output you want.

# Example python script to generate a netlist from a KiCad intermediate netlist
#
# Bob Cousins 2019.
#
"""
    @package
    Generate a net list file.

    Command line:
    python "pathToFile/netlist_gen.py" "%I" "%O"
"""

from __future__ import print_function

# Import the KiCad python helper module
import kicad_netlist_reader
import sys


def find_net (ref, pin):
    for net in netlist.nets:
        for node in net.getChildren('node'):
          if node.get("node", "ref") == ref and node.get("node", "pin") == pin:
              return net
    return None


if len(sys.argv) < 2:
    print("Usage ", __file__, "<netlist.xml> <output file>", file=sys.stderr)
    sys.exit(1)


# Generate an instance of a generic netlist, and load the netlist tree from
# the command line option. If the file doesn't exist, execution will stop
netlist = kicad_netlist_reader.netlist(sys.argv[1])


# Open a file to write to, if the file cannot be opened output to stdout
# instead
if len(sys.argv) > 2:
    try:
        f = open(sys.argv[2], 'w')
    except IOError:
        e = "Can't open output file for writing: " + sys.argv[2]
        print( __file__, ":", e, sys.stderr )
        f = sys.stdout
else:
    f = sys.stdout

# Generate a YAML style netlist

components = netlist.getInterestingComponents()

f.write ('---\n' )
f.write ('components:\n' )

for comp in components:
    f.write ('  - ref: %s\n' %  comp.getRef()  )
    f.write ('    value: %s\n' % comp.getValue() )

    part = comp.getLibPart()
    f.write ('    lib: %s\n' % (comp.getLibName() ) )
    f.write ('    device: %s\n' % (comp.getPartName() ) )
    f.write ('    footprint: %s\n' % (comp.getFootprint() ) )

    pins = part.element.getChild('pins')
    if pins:
        f.write ('    pins:\n' )
        for pin in pins.getChildren():
            f.write ('     - num: %s\n' % pin.get("pin", "num") )

            anet = find_net (comp.getRef(), pin.get("pin", "num") )
            if anet:
                f.write ('       net: %s\n' % anet.get("net", "name" )  )
            else:
                f.write ('       net: _none\n' )
f.close()
1 Like

This Kicon video may help too

1 Like

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