Well I don’t know what’s up with KiCAD but I wrote a Python script with a simple GUI that seems to solve my problem. Going to do more testing when I’m back in the office on Monday. This is the first real coding I’ve ever done so I’m sure it’s not perfect but it seems to work. Anyone experiencing the same problems I am is welcome to use it.
def main():
import ctypes
import tkinter
from tkinter import filedialog
import sys
#name the winddow and hide it
root = tkinter.Tk()
root.withdraw()
#open file dialog
ReadFile = filedialog.askopenfilename(filetypes = [("KiCAD Netlist","*.net")])
#if you don't select anything, close
if ReadFile == "":
ctypes.windll.user32.MessageBoxW(0, "Must open file", "Closing", 0)
raise SystemExit
ReadFile = open( ReadFile, "r" )
Lines = ReadFile.readlines()
ReadFile.close()
#save file dialog
WriteFile = filedialog.asksaveasfilename(filetypes = [("PADS Netlist","*.asc")],defaultextension = ".asc")
#if you don't select anything, close
if WriteFile == "":
ctypes.windll.user32.MessageBoxW(0, "Save as file required", "Closing", 0)
raise SystemExit
WriteFile = open( WriteFile, "w")
#Add Pads Header
WriteFile.write( "!PADS-POWERPCB-V5.0-MILS!\n" )
#Loop through the netlis line by line
con = 1
nen = 1
nod = 1
Comp2 = 0
for line in Lines:
line = line.strip()
#if the line is the KiCAD components header, start the PADS parts list
if line.find("components") != -1:
print ("FOUND THE PARTS")
WriteFile.write ("\n*PART* ITEMS\n")
#if the last line was a component, put the value on the same line
if Comp2 == 1:
start = line.find("value ") + 6
end = line.find(")")
WriteFile.write (line[start:end] + "\n")
Comp2 = 0
#if the line is a component, record the designator
if line.find("comp ") != -1:
s =str(con)
print ("found part #" + s)
con = con + 1
start = line.find("ref ") + 4
end = line.find(")")
WriteFile.write ( line[start:end].ljust(7, " ") + " " )
Comp2 = 1
#if the line is the KiCAD nets header, start the PADS net list
if line.find("nets") != -1:
print ("\nFOUND THE NETS")
WriteFile.write ("\n*NET*")
#if the line is a net, record the name
if line.find ("net ") != -1:
s = str(nen)
print ("found net #" + s)
nen = nen + 1
nod = 1
start = line.find("Net-(") + 5
end = line.find(")\")")
#if the name was manually entered in KiCAD it needs further trimming
if (line[start:end].find(" (code ")) == 0:
start = line. find( " (name ") + 7
end = len(line) - 1
WriteFile.write ("\n*SIGNAL* " + line[start:end] + "\n")
#if the line is a node, record it on the line below the net
if line.find("node") != -1:
s = str(nod)
print ("found node #" + s)
nod = nod + 1
start = line.find("ref ")
start = start + 4
end = line.find(") (")
line1 = line[start:end]
start = line.find("pin ")
start = start + 4
end = line.find("))")
WriteFile.write (line1 + "." + line[start:end] + " ")
#Tell me when you're done
print ( "DONE" )
s = str(con -1 )
print ( "Total Parts: " + s )
s = str(nen -1 )
print ( "Total Nets: " + s )
WriteFile.write ("\n*END* OF ASCII OUTPUT FILE\n")
ctypes.windll.user32.MessageBoxW(0, "Conversion is done.", "Done", 0)
main()