I am trying to create a netlist from a schematic in KiCAD to be opened in PADS. I want to use the plugin that comes with KiCAD to generate this file. My assumption was that KiCAD would somehow apply a format found in “netlist_form_pads-pcb.xsl” to its native netlist file and output a nice PADS netlist. Unfortunately what comes out the other end is a .xml document that is nothing like the expected file. I take it this is the “intermediate netlist” file referenced by the Eschema documentation? The documentation now directs me to apply the netlist form with xsltproc.exe, which as far as I can tell KiCAD already did to generate the intermediate netlist in the first place.
Is KiCAD broken or am I just doing something wrong? The documentation makes it seem straight forward but so far my experience has been anything but.
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()
A script is a good idea, as you’ll likely also need a mapping table for the KiCAD names -> PADS Names.
At some point pin-labels will need checking too,
The purpose for this is we want to perform schematic capture and netlist generation which will then be sent to a third party for board layout. The nets are the important part. Not really concerned about the part names at the moment they will have to be changed anyways.
You might want to look at adding a Value field, to your Script, as PADS can import this NET file variant fine.
(ie it does not require a @DecalName, the ,value can append anytime)
I will look into including both. At the moment the script only pulls the reference and value out of the KiCAD netlist, not the KiCAD library or module name,
Sounds ok.
If you expect to do many designs using this flow, another approach is to add fields, and I find this NET output is easily created, which should be easy to parse in your script.
and if found, insert those into the PADS NET, which (greatly) reduces manual post work, and gives you more absolute control over the design.
Addit: PADS currently coughs warnings on single-pin nets, so it may pay to check that in a script,vand not export single-node net cases.
PADS does allow comments under REMARK, so another suggestion would be to add the PinCount and connected pins list, in the PART section, as comments, which would ease manual part mapping.
This would slow the script down a little, but net conversion is not speed critical.
I’m having difficulty generating net list with PADS format, Does anyone have instruction on how to generate the net list in PADS, thank you for time in advance
Hi Joan thank you for you reply, I need to generate Net list in PADS format , below is what i tried to do
After completing the schematics, I attempted to create the netlist as follow
under the Net list menu i have currently four options and they are Pcbnew (selected), Orcad CADStar and Spice (all three are not selected)
I selected Add Plugin
under Plugins menu I selected Browse Plugins
Selected the folder Scripting, then selected Plugins
I chose netlist_form_pads-pcb.xsl
this file gave me a NETLIST command line xsltproc -o “%O” “C:\Program Files\KiCad\bin\scripting\plugins\netlist_form_pads-pcb.xsl” "%I"
I assigned a name to the file " NET_to_PADS"
Now I have a new tab under the net list menu called NET_to_PADS
I selected the option (default format)
I selected Generate , gave option for file name and i left the default name then i clicked save
the output of the file is an XML file, which i have no what to do with it ,and that is where i stopped
I got 2 outputs for the same workflow.
One is .xml file and the other a .pads file.
The pads file still has the problematic string at the front that needs to be modified/replaced according to this post further up (see link at bugtracker for details)
If you do this more often you probably want to modify the xsl file, from this:
is sufficiently modified to what PADS want’s to see there for the latter part of each line (how does PADS assign footprints - I have no idea) then you got a winner.
If you screw it up, PADS won’t know what to do with the Reference designators in the net list further down, as the footprints are unknown to it and probably throw a hissy-fit about how you could feed it such erroneous data.
[quote=“Joan_Sparky, post:19, topic:4511”]
…
Thank you Joan, I have to buy beer one day I copied and pasted the line command you sent and still KiCad generated one file which is XML type, I tried both the original script file “netlist_form_pads-pcb.xsl” and also i copied and pasted the original file in different directory ,then I edit the script file to include what PCB Wiz suggested which is changline line 18 from PADS-PCB to !PADS-POWERPCB-V2.0-MILS!
I"m stuck and not sure how to proceed from here , is there another script file that I should use that i missed