Exporting KiCad DSN to Text
I finally got round to exporting the DSN file to some intermediate files that are easier to work with:
- pcb.txt
- nets.txt
- parts.txt
The code is rather bloated so later I will try and remove the S-Expr linked list.
The "pcb" file looks like this (units are um):
pcb: 130810 -95250 130810 -120650 175260 -120650 175260 -95250 130810 -95250 130810 -95250
I can write some code to consider an arbitrary shape but a rectangle is good enough for now.
The "nets":
nets: C1-1 D2-1 Q1-2 R2-1 C1-2 D1-2 D3-2 D4-2 D5-2 R3-1 D1-1 D2-2 D3-1 J1-3 D4-1 J1-4 D5-1 J1-5 J1-1 R1-2 R3-2 J1-2 Q1-3 R1-1 J1-6 Q1-1 R2-2
The nets will need to be converted into number for the router.
And finally the "pins" or parts:
Component Surface/Pin X Y Rot C1 front 154940 -105410 180 1 0 0 0 2 5000 0 0 D1 front 165100 -110490 180 1 0 0 0 2 7620 0 0 D2 front 157480 -107950 0 1 0 0 0 2 7620 0 0 D3 front 139700 -107950 0 1 0 0 0 2 7620 0 0 D4 front 139700 -110490 0 1 0 0 0 2 7620 0 0 D5 front 139700 -113030 0 1 0 0 0 2 7620 0 0 J1 front 135890 -102870 0 1 0 0 0 2 0 -2540 0 3 0 -5080 0 4 0 -7620 0 5 0 -10160 0 6 0 -12700 0 Q1 front 163830 -101600 90 2 1270 1270 90 3 2540 0 90 1 0 0 90 R1 front 147320 -102870 180 1 0 0 0 2 7620 0 0 R2 front 157480 -105410 0 1 0 0 0 2 7620 0 0 R3 front 147320 -105410 180 1 0 0 0 2 7620 0 0
All the pin locations need to be processed (translated and rotated).
The next step is to build the "links" list:
SRC DST 1 7 7 8 2 13 13 22 3 9 4 10 5 11 6 24 24 25 12 14 14 19 14 15 15 16 16 21 17 18 18 23 18 20 26 27
The then build a "map":
25 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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