Convert freePCB footprints to Kicad footprints

OK, here goes attempting to attach a zip file.

freePCBtestfootprints.zip (1.6 KB)

Cheers

ian

The format should look something like that.

SPDT Toggle.kicad_mod (1.2 KB)

Hi Jos,

For some reason I get a “Oops! That page doesn’t exist or is private” message when I try to download your file.

Cheers

Ian

It’s a mystery to me as to why. Simply attached as per usual. There are no setting available to me to set anything private unless there are some ‘secret’ profile settings.

Any admins around to fix this!?!

Below the actual content of that mod file.

(module "vfedtec:SPDT Toggle" (layer F.Cu) (tedit 5DF5542E)
  (descr "PCB mount miniature SPDT toggle Switch with centre off")
  (tags "spdt toggle switch")
  (fp_text reference "S" (at 0 -10.16 unlocked) (layer F.SilkS)
    (effects (font (size 1 1) (thickness 0.15)))
  )
  (fp_text value "SPDT Toggle" (at 0 -8.509 unlocked) (layer F.Fab)
    (effects (font (size 1 1) (thickness 0.15)))
  )
  (fp_line (start -2.159 4.064) (end -2.159 -4.064) (layer F.SilkS) (width 0.254))
  (fp_line (start 2.159 4.064) (end -2.159 4.064) (layer F.SilkS) (width 0.254))
  (fp_line (start 2.159 -4.064) (end 2.159 4.064) (layer F.SilkS) (width 0.254))
  (fp_line (start -2.159 -4.064) (end 2.159 -4.064) (layer F.SilkS) (width 0.254))
  (fp_text user "Ian Thompson-Bell" (at 0 -6.985) (layer F.SilkS)
    (effects (font (size 1 1) (thickness 0.15)))
  )
  (fp_text user "MultiComp data sheet" (at 0 -5.334) (layer F.SilkS)
    (effects (font (size 1 1) (thickness 0.15)))
  )
  (pad "3" thru_hole circle (at 0 2.54) (size 1.905 1.905) (drill 1.2192) (layers *.Cu *.Mask))
  (pad "2" thru_hole circle (at 0 0) (size 1.905 1.905) (drill 1.2192) (layers *.Cu *.Mask))
  (pad "5" thru_hole circle (at 0 -2.54) (size 1.905 1.905) (drill 1.2192) (layers *.Cu *.Mask))
)

First try and delete and upload the file again. @ChrisGammell recently did some work to allow some extensions to be uploaded. I don’t know if the link somehow got broken or that file extension got disallowed by mistake. You could also try a quick zip of it and see if that makes a difference. That might narrow down the cause.

Thanks hermit. I think it’s the extension.
Just came to mind that we actually had that very same case a few weeks ago.
Maybe the space in name is a problem.

I have created an updated version of the script which you can find at https://github.com/bobc/kicad-pcblib

I have added support for MM and MIL units. The parser is reworked to allow indented or non-indented input. I have also added conversion of “text” objects.

As a first cut I think this will give a basic conversion without crashing so much, at least it works on examples I was able to find. The original script made quite a few assumptions and applied a “house style” for things like text properties, so the conversion is not that authentic. There’s also a few wrinkles I encountered in the freepcb, e.g. layer numbers and pad shape numbers don’t seem to be documented.

3 Likes

Many thanks for doing this Bob. I will check it out, test it some of my freePCB footprints and report back.

Cheers

Ian

Hi Bob, your script works pretty well. I had a lot of errors due to unexpected keys, namely top_mask, top_paste, bottom_mask and bottom_paste. However, these all apply to SMD parts of which I have none so they maybe errors due to freePCB itself. Anyway I deleted all such lines and it reaches the end of my 10,000 line library without errors and then proceeds to create the actual Kicad libraries. It is OK for the first 17 entries then throws an error on this part:

name: “Z21807C”
author: “Ian Thompson-Bell”
source: “OEp Data Sheet”
description: “OEP Z21807C 10K:10K bridging transformer”
units: NM
sel_rect: -12842900 -9992900 12842900 9992900
ref_text: 1270000 -3810000 -1590000 0 127000
value_text: 2540000 -5588000 -9144000 0 254000
centroid: 0 0 0 0
text: “S” 1270000 -8128000 -4318000 0 127000 0 4
text: “P-” 1270000 2540000 -4318000 0 127000 0 4
text: “S” 1270000 7112000 -4318000 0 127000 0 4
text: “P+” 1270000 -5080000 -4318000 0 127000 0 4
text: “1” 1270000 -9398000 -6096000 0 127000 0 4
text: “S1+” 1270000 2540000 2540000 0 127000 0 4
text: “S1-” 1270000 -1270000 2540000 0 127000 0 4
text: “S2+” 1270000 -5715000 2540000 0 127000 0 4
text: “S2-” 1270000 -9525000 2540000 0 127000 0 4
text: “Z21807C” 1270000 -4572000 7620000 0 127000 0 4
outline_polyline: 177800 -12500000 -9650000
next_corner: 12500000 -9650000 0
next_corner: 12500000 9650000 0
next_corner: -12500000 9650000 0
close_polyline: 0
n_pins: 9
pin: “1” 900000 -7620000 -5400000 90
top_pad: 2 1740000 0 0 0
inner_pad: 1 1740000 0 0 0 0
bottom_pad: 2 1740000 0 0 0
pin: “2” 900000 -3810000 -5400000 270
top_pad: 1 1740000 0 0 0
inner_pad: 1 1740000 0 0 0 0
bottom_pad: 1 1740000 0 0 0
pin: “4” 900000 3810000 -5400000 270
top_pad: 1 1740000 0 0 0
inner_pad: 1 1740000 0 0 0 0
bottom_pad: 1 1740000 0 0 0
pin: “5” 900000 7620000 -5400000 270
top_pad: 1 1740000 0 0 0
inner_pad: 1 1740000 0 0 0 0
bottom_pad: 1 1740000 0 0 0
pin: “6” 900000 7620000 5400000 90
top_pad: 1 1740000 0 0 0
inner_pad: 1 1740000 0 0 0 0
bottom_pad: 1 1740000 0 0 0
pin: “7” 900000 3810000 5400000 90
top_pad: 1 1740000 0 0 0
inner_pad: 1 1740000 0 0 0 0
bottom_pad: 1 1740000 0 0 0
pin: “8” 900000 0 5400000 90
top_pad: 1 1740000 0 0 0
inner_pad: 1 1740000 0 0 0 0
bottom_pad: 1 1740000 0 0 0
pin: “9” 900000 -3810000 5400000 90
top_pad: 1 1740000 0 0 0
inner_pad: 1 1740000 0 0 0 0
bottom_pad: 1 1740000 0 0 0
pin: “10” 900000 -7620000 5400000 90
top_pad: 1 1740000 0 0 0
inner_pad: 1 1740000 0 0 0 0
bottom_pad: 1 1740000 0 0 0

The error trace is:

Traceback (most recent call last):
File “./bobsparser.py”, line 903, in
main ()
File “./bobsparser.py”, line 898, in main
sexp = i.kicad_sexp ()
File “./bobsparser.py”, line 345, in kicad_sexp
sexp.extend (i.kicad_sexp ())
File “./bobsparser.py”, line 604, in kicad_sexp
assert self.Angle == 0
AssertionError

(I renamed the python script to bobsparse.pyr simply to avoid confusion on my part)

Cheers

Ian

I see the problem, as well as a few others. I will have some time at the weekend to look at it.

1 Like

That is very kind Bob. No rush. I am just very pleased at the prospect of not having to manually input over 100 footprints.

Cheers

Ian

1 Like

I have fixed up various issues I found, also implemented arc type in polylines which helps a lot. For test data I have been using a library called midcom.fpl which I found in the issues for the original repo.

The original Freepcb code seems to be unmaintained, but there is apparently a fork called FreePcb-2. I couldn’t find any source code for that, so the seem to be violating GPL with that.

Anyway let me know if you have any issues.

I started using freePCB about 10 years ago. At that time the recommended stable version was 1.354 which I still use. However, I think the file format may have its own separate version numbering. Mine is currently at 1.344 as you can see in this snippet from the beginning of a .fpc file:

[options]

version: 1.354
file_version: 1.344
project_name: “7HP3TrelaygainHPF”
full_library_folder: “z:\media\ctc\freepcb\lib”
CAM_folder: “F:\freepcb\projects\7HP3TrelaygainHPF\CAM”
ses_file_path: “”
SMT_connect_copper: “0”
default_glue_width: “635000”
dsn_flags: “0”
dsn_bounds_poly: “0”
dsn_signals_poly: “0”
autosave_interval: 0
netlist_import_flags: 451
units: MM

Cheers

ian

Bob, I just tried your new version of the freePCB footprint convertor and it successfully converted all 200 of my freePCB footprints. Looking at them in Kicad they all seem have have been converted correctly. Not made any detailed measurements yet but they all look basically correct. Many thanks for your efforts.

Cheers

Ian

1 Like

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