Script: name of the net and the connector

I am struggling to make a script that collects the correct data. The script should create a semicolon-separated list. I want to establish a relationship between the name of the net and the connector. I encounter a problem when the net is connected to more than one connector pin.

Result:

Shield;J602.1
Shield;J702.1
Shield;J604.1
Shield;J802.1
Spare;J508.1
TBat +;J501.1
TBat +;J801.7

Part of the netlist
" (net (code “49”) (name “Magnet Back +”)
(node (ref “J202”) (pin “9”) (pinfunction “Pin_9”) (pintype “passive”)))
(net (code “50”) (name “Magnet Front+”)
(node (ref “J202”) (pin “8”) (pinfunction “Pin_8”) (pintype “passive”)))
(net (code “51”) (name “Mulimeter + High voltage”)
(node (ref “J801”) (pin “9”) (pinfunction “Pin_9”) (pintype “passive”)))
(net (code “52”) (name “Mulimeter - High voltage”)
(node (ref “J801”) (pin “10”) (pinfunction “Pin_10”) (pintype “passive”)))
(net (code “53”) (name “Multimeter +”)
(node (ref “J407”) (pin “1”) (pinfunction “Pin_1”) (pintype “passive”))
(node (ref “J801”) (pin “1”) (pinfunction “Pin_1”) (pintype “passive”)))
(net (code “54”) (name “Multimeter -”)
(node (ref “J408”) (pin “1”) (pinfunction “Pin_1”) (pintype “passive”))
(node (ref “J801”) (pin “2”) (pinfunction “Pin_2”) (pintype “passive”)))
(net (code “55”) (name “N Safety Box Out”)
(node (ref “J901”) (pin “1”) (pinfunction “Pin_1”) (pintype “passive”)))
(net (code “56”) (name “N X1.9”)
(node (ref “J303”) (pin “1”) (pinfunction “Pin_1”) (pintype “passive”)))
(net (code “57”) (name “PE Out”)
(node (ref “J901”) (pin “5”) (pinfunction “Pin_5”) (pintype “passive”))
(node (ref “P901”) (pin “3”) (pinfunction “EARTH”) (pintype “passive”)))
(net (code “58”) (name “PE X1.1”)
(node (ref “J307”) (pin “1”) (pinfunction “Pin_1”) (pintype “passive”)))
(net (code “59”) (name “RS485_A_module”)
(node (ref “J601”) (pin “9”) (pinfunction “Pin_9”) (pintype “passive”)))
(net (code “60”) (name “RS485_B_module”)
(node (ref “J601”) (pin “8”) (pinfunction “Pin_8”) (pintype “passive”)))
(net (code “61”) (name “Res_In”)
(node (ref “J405”) (pin “1”) (pinfunction “Pin_1”) (pintype “passive”)))
(net (code “62”) (name “Res_Out”)
(node (ref “J406”) (pin “1”) (pinfunction “Pin_1”) (pintype “passive”)))
(net (code “63”) (name “Shield”)
(node (ref “J602”) (pin “1”) (pinfunction “Pin_1”) (pintype “passive”))
(node (ref “J702”) (pin “1”) (pinfunction “Pin_1”) (pintype “passive”))
(node (ref “J704”) (pin “1”) (pinfunction “Pin_1”) (pintype “passive”))
(node (ref “J802”) (pin “1”) (pinfunction “Pin_1”) (pintype “passive”)))
(net (code “64”) (name “Spare”)
(node (ref “J508”) (pin “1”) (pinfunction “Pin_1”) (pintype “passive”)))
(net (code “65”) (name “TBat +”)
(node (ref “J501”) (pin “1”) (pinfunction “Pin_1”) (pintype “passive”))
(node (ref “J801”) (pin “7”) (pinfunction “Pin_7”) (pintype “passive”)))
(net (code “66”) (name “TBat -”)
(node (ref “J502”) (pin “1”) (pinfunction “Pin_1”) (pintype “passive”))
(node (ref “J801”) (pin “8”) (pinfunction “Pin_8”) (pintype “passive”)))
(net (code “79”) (name “eth1”)
(node (ref “J701”) (pin “8”) (pinfunction “Pin_8”) (pintype “passive”))
(node (ref “J903”) (pin “1”) (pintype “passive”)))
(net (code “80”) (name “eth2”)
(node (ref “J701”) (pin “7”) (pinfunction “Pin_7”) (pintype “passive”))
(node (ref “J903”) (pin “2”) (pintype “passive”)))
(net (code “81”) (name “eth3”)
(node (ref “J701”) (pin “6”) (pinfunction “Pin_6”) (pintype “passive”))
(node (ref “J903”) (pin “3”) (pintype “passive”)))
(net (code “82”) (name “eth4”)
(node (ref “J701”) (pin “5”) (pinfunction “Pin_5”) (pintype “passive”))
(node (ref “J903”) (pin “4”) (pintype “passive”)))
(net (code “83”) (name “eth5”)
(node (ref “J701”) (pin “4”) (pinfunction “Pin_4”) (pintype “passive”))
(node (ref “J903”) (pin “5”) (pintype “passive”)))
(net (code “84”) (name “eth6”)
(node (ref “J701”) (pin “3”) (pinfunction “Pin_3”) (pintype “passive”))
(node (ref “J903”) (pin “6”) (pintype “passive”)))
(net (code “85”) (name “eth7”)
(node (ref “J701”) (pin “2”) (pinfunction “Pin_2”) (pintype “passive”))
(node (ref “J903”) (pin “7”) (pintype “passive”)))
(net (code “86”) (name “eth8”)
(node (ref “J701”) (pin “1”) (pinfunction “Pin_1”) (pintype “passive”))
(node (ref “J903”) (pin “8”) (pintype “passive”)))
(net (code “87”) (name “gnd”)
(node (ref “J902”) (pin “2”) (pinfunction “Pin_2”) (pintype “passive”))
(node (ref “J902”) (pin “4”) (pinfunction “Pin_4”) (pintype “passive”))
(node (ref “J902”) (pin “6”) (pinfunction “Pin_6”) (pintype “passive”)))
(net (code “88”) (name “unconnected-(J201-Pin_12-Pad12)”)
(node (ref “J201”) (pin “12”) (pinfunction “Pin_12”) (pintype “passive”)))
(net (code “89”) (name “unconnected-(J201-Pin_13-Pad13)”)
(node (ref “J201”) (pin “13”) (pinfunction “Pin_13”) (pintype “passive”)))
(net (code “90”) (name “unconnected-(J201-Pin_14-Pad14)”)
(node (ref “J201”) (pin “14”) (pinfunction “Pin_14”) (pintype “passive”)))
(net (code “91”) (name “unconnected-(J201-Pin_15-Pad15)”)
(node (ref “J201”) (pin “15”) (pinfunction “Pin_15”) (pintype “passive”)))
(net (code “92”) (name “unconnected-(J201-Pin_16-Pad16)”)
(node (ref “J201”) (pin “16”) (pinfunction “Pin_16”) (pintype “passive”)))
(net (code “93”) (name “unconnected-(J202-Pin_12-Pad12)”)
(node (ref “J202”) (pin “12”) (pinfunction “Pin_12”) (pintype “passive”)))
(net (code “94”) (name “unconnected-(J202-Pin_13-Pad13)”)
(node (ref “J202”) (pin “13”) (pinfunction “Pin_13”) (pintype “passive”)))
(net (code “95”) (name “unconnected-(J202-Pin_14-Pad14)”)
(node (ref “J202”) (pin “14”) (pinfunction “Pin_14”) (pintype “passive”)))
(net (code “96”) (name “unconnected-(J202-Pin_15-Pad15)”)
(node (ref “J202”) (pin “15”) (pinfunction “Pin_15”) (pintype “passive”)))
(net (code “97”) (name “unconnected-(J202-Pin_16-Pad16)”)
(node (ref “J202”) (pin “16”) (pinfunction “Pin_16”) (pintype “passive”)))
(net (code “98”) (name “unconnected-(J701-Pin_10-Pad10)”)
(node (ref “J701”) (pin “10”) (pinfunction “Pin_10”) (pintype “passive”)))
(net (code “99”) (name “unconnected-(J701-Pin_11-Pad11)”)
(node (ref “J701”) (pin “11”) (pinfunction “Pin_11”) (pintype “passive”)))
(net (code “100”) (name “unconnected-(J701-Pin_12-Pad12)”)
"

What sort of programming experience do you have? What language / Tools?

In the PCB editor you can directly write and run scripts. The Schematic Editor does not have a scripting interface yet (Hopefully in a few years)

For an external script that reads KiCad’s file, you can use any language. KiCad’s file formats are in S-expression format, and there are probably libraries to read such files into memory in nearly every decent programming or scripting language.

You can find more on KiCad’s file formats via the KiCad website (and then Contribute / Developers from the menu) A direct link:

If you need more help, then show us what you’ve done, and where you get stuck.

Hi
Thank you for the reply.
I have exported the net list and I’m running regular expressions in Python.

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