Connections disappear when importing netlist in pcbnew

Hi there, I know that in KiCad 6 the recommended way to update the layout from a schematic is by using the “Update PCB from Schematic…” button, however in my use case I would like to generate the netlist from a personal project (simple HDL tool) and be able to load it directly without using eeschema.

In an attempt to understand the new s-expr netlist file format (which I haven’t found documentation for) I created a simple schematic with some connections and exported it as a .net file. When importing this netlist into pcbnew, it looks like all the connections were lost even though they are present in the .net file. Furthermore, when I use the “Update PCB from Schematic…” button, I do see all the correct connections.

Here is a simple example schematic:

The result of updating the PCB from the schematic:

The result of importing the corresponding netlist file:

I tried with different schematics, components, footprints and netlist import options and I never get the connections, here is the netlist if it helps:

(export (version "E")
  (design
    (source "C:\\Users\\Nathan\\Desktop\\Lab\\lab\\lab.kicad_sch")
    (date "14/05/2022 10:38:56")
    (tool "Eeschema (6.0.4)")
    (sheet (number "1") (name "/") (tstamps "/")
      (title_block
        (title)
        (company)
        (rev)
        (date)
        (source "lab.kicad_sch")
        (comment (number "1") (value ""))
        (comment (number "2") (value ""))
        (comment (number "3") (value ""))
        (comment (number "4") (value ""))
        (comment (number "5") (value ""))
        (comment (number "6") (value ""))
        (comment (number "7") (value ""))
        (comment (number "8") (value ""))
        (comment (number "9") (value "")))))
  (components
    (comp (ref "D1")
      (value "LED")
      (footprint "LED_THT:LED_D4.0mm")
      (libsource (lib "Device") (part "LED") (description "Light emitting diode"))
      (property (name "Sheetname") (value ""))
      (property (name "Sheetfile") (value "lab.kicad_sch"))
      (sheetpath (names "/") (tstamps "/"))
      (tstamps "85e9d98c-58e1-4f28-8c17-acf434e6ec93"))
    (comp (ref "R1")
      (value "R1k")
      (footprint "Resistor_THT:R_Axial_DIN0414_L11.9mm_D4.5mm_P15.24mm_Horizontal")
      (libsource (lib "Device") (part "R") (description "Resistor"))
      (property (name "Sheetname") (value ""))
      (property (name "Sheetfile") (value "lab.kicad_sch"))
      (sheetpath (names "/") (tstamps "/"))
      (tstamps "61d500a1-1002-4639-8fcd-443ce517485c")))
  (libparts
    (libpart (lib "Device") (part "LED")
      (description "Light emitting diode")
      (docs "~")
      (footprints
        (fp "LED*")
        (fp "LED_SMD:*")
        (fp "LED_THT:*"))
      (fields
        (field (name "Reference") "D")
        (field (name "Value") "LED")
        (field (name "Datasheet") "~"))
      (pins
        (pin (num "1") (name "K") (type "passive"))
        (pin (num "2") (name "A") (type "passive"))))
    (libpart (lib "Device") (part "R")
      (description "Resistor")
      (docs "~")
      (footprints
        (fp "R_*"))
      (fields
        (field (name "Reference") "R")
        (field (name "Value") "R")
        (field (name "Datasheet") "~"))
      (pins
        (pin (num "1") (name "") (type "passive"))
        (pin (num "2") (name "") (type "passive")))))
  (libraries
    (library (logical "Device")
      (uri "C:\\Program Files\\KiCad\\6.0\\share\\kicad\\symbols\\/Device.kicad_sym")))
  (nets
    (net (code "1") (name "+3V3")
      (node (ref "R1") (pin "1") (pintype "passive")))
    (net (code "2") (name "GND")
      (node (ref "D1") (pin "1") (pinfunction "K") (pintype "passive")))
    (net (code "3") (name "Net-(D1-Pad2)")
      (node (ref "D1") (pin "2") (pinfunction "A") (pintype "passive"))
      (node (ref "R1") (pin "2") (pintype "passive")))))

Am I missing something or doing something wrong?

Thanks for your help!

First: When bugs are suspected, always include the full KiCad version. You can copy it from Help / About KiCad / Copy Version Info and post it.

I suspected you are using KiCad V6.0.3 (which has a serious bug and was taken off the market within a few days after it’s release). I do see the string “6.0.4” in your netlist, so it’s not that 6.0.3 version.


Also:
Are you aware of SKiDL?
It’s a python library for generating KiCad netlist info from a python program. I did some experiments with it and quite liked it, but for my use the regular schematic entry fits better. I’m not sure if it has been updated for KiCad V6 though.

There is quite a lot of information abut KiCads file formats on: File Formats | Developer Documentation | KiCad but unfortunately the new netlist format is not described there. This may be worth a bug report on Gitlab.

What messages do you get during: Pcb Editor / File / Import / Netlist ?

I just tried it with an incomplete schematic (not all footprints assigned) but I did get ratsnest lines for the footprints that got imported.

Thanks for the reply, I updated to 6.0.5 just in case but I still don’t see the connections,
SKiDL looks nice, they seem to use the new netlist format when targeting KiCad, so I might have a look at the source code. The tool I am creating (only for educational purposes) is very similar.

I did look at the format section of the docs, but as you mentioned this part is missing. Good idea, I will open a ticket on Gitlab to ask for documentation of the s-expr netlist format.

@paulvdh When I import the netlist, I don’t get any errors or warnings, thanks for trying could you maybe share the netlist file you generated to verify that it works on my setup too? (I also tried on the latest macOS version on KiCad 6.0.5 and I get the same results)

If anyone is curious, here is the Gitlab issue to ask for documentation on the new netlist file format using S expressions: Document the s-expr netlist file format (#15) · Issues · KiCad / KiCad Web Services / kicad-dev-docs · GitLab

Update: When I load a netlist from a new pcbnew window (outside of a KiCad project), the ratsnets are not visible, however when I load the netlist from inside a KiCad project folder (with a .pro file), then it seems to be working just fine (it’s maybe a related to the resolution mechanism, I am not sure).