Output to PADS PCB Netlist Broken?

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.

Thanks for the help.

https://lists.launchpad.net/kicad-developers/msg05156.html

The information in the link above seems to me to indicate I am doing this right but KiCAD is simply not responding in the correct way.

Anyone know of any translators out there for KiCAD .net to PADS .asc?

See my earlier post, around the PADS header string error, being wrong for anything remotely recent.

This exports in the form

*PART*
RefDes  eESchemaFootprint

and PADS expects either

*PART*
RefDes  PADS_PartType

or if you want to over-rule a default footprint decal, you can export this

*PART*
RefDes  PADS_PartType@PADS_DecalFootprintOverride

which means you need to either edit the Footprint field, or use some lookup table script.

When eeschema supports Python Scripting, fixing and expanding this will become much easier.
Not sure of the time line on that ?

I saw your post. My problem is not with the header. I would manually fix the header without complaint.

My issue is my output is an .xml intermediate netlist, not remotely close to a PADS netlist.

I get the output below from this netlist command
( ie it actually runs netlist_form_pads-pcb.xsl )

Command:
xsltproc -o “%O” “C:\Program Files\KiCad\bin\scripting\plugins\netlist_form_pads-pcb.xsl” “%I”

Output: (after applying header fix from other thread)

!PADS-POWERPCB-V1-MILS!
*PART*
 J1 Pin_Headers:Pin_Header_Angled_1x10
 C1n1 C0805
 TH1 Resistors_SMD:R_1206
 K100 Resistors_SMD:R_0805

*NET*
*SIGNAL* /NTH
 J1.9
 TH1.2
*SIGNAL* +5V
 U2.14
 J3.1
 J1.1
 C1n1.1
 U1.5

After running:
xsltproc -o “%O” “C:\Program Files\KiCad\bin\scripting\plugins\netlist_form_pads-pcb.xsl” “%I”

My output is:

etc.

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()
1 Like

Strange - maybe your netlist_form_pads-pcb.xsl is corrupt ?
Mine netlist_form_pads-pcb.xsl is

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--XSL style sheet to EESCHEMA Generic Netlist Format to PADS netlist format
    Copyright (C) 2010, SoftPLC Corporation.
    GPL v2.

    How to use:
        see eeschema.pdf, chapter 14 FIXED PADS header String 
-->

<!DOCTYPE xsl:stylesheet [
  <!ENTITY nl  "&#xd;&#xa;"> <!--new line CR, LF -->
]>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes" indent="no"/>

<xsl:template match="/export">
    <xsl:text>!PADS-POWERPCB-V1-MILS!&nl;*PART*&nl;</xsl:text>
    <xsl:apply-templates select="components/comp"/>
    <xsl:text>&nl;*NET*&nl;</xsl:text>
    <xsl:apply-templates select="nets/net"/>
    <xsl:text>*END*&nl;</xsl:text>
</xsl:template>

<!-- for each component -->
<xsl:template match="comp">
    <xsl:text> </xsl:text>
    <xsl:value-of select="@ref"/>
    <xsl:text> </xsl:text>
    <xsl:choose>
        <xsl:when test = "footprint != '' ">
            <xsl:apply-templates select="footprint"/>
        </xsl:when>
        <xsl:otherwise>
            <xsl:text>unknown</xsl:text>
        </xsl:otherwise>
    </xsl:choose>
    <xsl:text>&nl;</xsl:text>
</xsl:template>

<!-- for each net -->
<xsl:template match="net">
    <!-- nets are output only if there is more than one pin in net -->
    <xsl:if test="count(node)>1">
        <xsl:text>*SIGNAL* </xsl:text>
        <xsl:choose>
            <xsl:when test = "@name != '' ">
                <xsl:value-of select="@name"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:text>N-</xsl:text>
                <xsl:value-of select="@code"/>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:text>&nl;</xsl:text>
        <xsl:apply-templates select="node"/>
    </xsl:if>
</xsl:template>

<!-- for each node -->
<xsl:template match="node">
    <xsl:text> </xsl:text>
    <xsl:value-of select="@ref"/>
    <xsl:text>.</xsl:text>
    <xsl:value-of select="@pin"/>
    <xsl:text>&nl;</xsl:text>
</xsl:template>

</xsl:stylesheet>

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,

eg KiCad uses

(comp (ref K1)
  (value 1233R)
  (footprint Resistors_SMD:R_0805)

whilst PADS can accept

 K1    PartType  

eg valid parttypes are like R0805 or RES0805 from memory.

or, you can export as

 K1  PartType@DecalOverride,ValueField

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.

That should work fine for that.

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)

*PART*       ITEMS
C1               CAP1206,100n
C2               CAP1206
R1               RES1206,4.7k
R2               RES1206

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.

(comp (ref C1n1)
  (value 100n)
  (footprint C0805)
  (fields
    (field (name Field4nn) C1_Field4c1)
    (field (name PADS_PartType) CAP0805)
    (field (name PADS_Decal) 0805))
  (libsource (lib device) (part C))
  (sheetpath (names /) (tstamps /))
  (tstamp 5760DAC6))

Your script could test for those optional fields like

    (field (name PADS_PartType) CAP0805)
    (field (name PADS_Decal) 0805))

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

What did you try?
What fails?
:neutral_face:
You’re problem report is rather broad and unspecific…

PS: the bugfix is still not implemented… tested in:

Application: kicad
Version: (2017-02-10 revision 1bcbbb4)-makepkg, release build
Libraries: wxWidgets 3.0.2
libcurl/7.51.0 OpenSSL/1.0.2j zlib/1.2.8 libssh2/1.8.0 nghttp2/1.16.1 librtmp/2.3
Platform: Windows 7 (build 7601, Service Pack 1), 64-bit edition, 64 bit, Little endian, wxMSW

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 look forward to hear you response

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:

...
<xsl:template match="/export">
    <xsl:text>*PADS-PCB*&nl;*PART*&nl;</xsl:text>
...

to this:

...
<xsl:template match="/export">
    <xsl:text>!PADS-POWERPCB-V2.0-MILS!&nl;*PART*&nl;</xsl:text>
...

I’m not getting two files, only XML file is what i’m getting.

PCB WIZ comment, i’m not sure how to use the information

Alos what does “if you have correctly mapped eeschema.footprints to PADS …”

Thank you again for your help

Sorry, don’t use this stuff, so I didn’t tell all I did.

In the PADS dialog, my command line looks like this:

xsltproc -o “%O.pads” “C:\Program Files\KiCad\bin\scripting\plugins\netlist_form_pads-pcb.xsl” “%I”

If you just got -o “%O” in that string, the pads file will have no extension at all, but the same name as the xml file.

I guess it means if your KiCAD (ref<>fp) association in the pads file like this:

...
*PART*
 U103 SOTx:SOT-353
 U104 SOTx:SOT-323
 Q101 SOTx:SOT-363
 Y101 SMDx:Crystal_3.2x1.5_2P
 U101 xSOP:xSSOP-10-0.5-Wb3-Wp5
 U102 xSOP:xSSOP-8-0.65-Wb3-Wp4
...

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.
:wink:

[quote=“Joan_Sparky, post:19, topic:4511”]

Thank you Joan, I have to buy beer one day :slight_smile: 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

Thank you again