← Back to team overview

kicad-developers team mailing list archive

Re: S-expression footprint library format.

 

On 10/8/2012 10:42 AM, Kaspar Bumke wrote:
Not that I am planning.  The directory and it's footprint files are the library.

So what Lorenzo said was wrong? What is this library table then?

The library table fixes a long standing bug in Pcbnew when duplicate footprint names exist in more than one library. Let's say you have a footprint named FOO. Pcbnew use the library search order and picks the first occurrence FOO. If you insert a new library with a part named FOO in front of the library containing the current FOO footprint, when you reload the board the new FOO footprint will be used. The library table is used to associate the footprint to it's proper library. This way you can have as many libraries with a FOO footprint as you want without worrying about it being accidentally replaced by inserting another library into your project.


Once the library table is implemented, as long as there is Pcbnew plugin that supports reading and writing footprint libraries you will be able to convert to and from any format.  In your case, conversion from the legacy (current) format to the s-expression (new) format will not be a problem.

Sure, but what I had implemented for now was a simple line-reader of
the existing format. This too took quite a lot of time figuring out
what the format is as it was not properly documented. I just wanted to
stress how important it would be for me to have it all clearly
documented. In my case at least, documentation would be more help than
actual working code :D

I do plan on documenting them at some point. I hope that I will have a least some minimal documentation when the new formats become the default.


I guess I will have to go ahead and look at the files themselves and
start documenting.  Is there a specific place in the code that you can
point me to that might help me with this? I think I tried looking for
it before but was hindered by the fact that I don't know a lot of the
names and naming conventions yet.

The s-expression formatting is very human readable which was one of the primary goals. If you build KiCad, enable the s-expression file format, and save some sample boards and libraries, you should be able to get a pretty good idea of the new format.


As an aside, I had tried using Python scripting (my site is written in
Python too) to aide me in parsing the libraries but at the time it
actually seemed simpler to write a line-reader myself as the Python
objects didn't seem to contain all the info I needed yet.


You really need to try to take advantage of the new built in Python scripting. I believe the plugin support is already available (someone correct me if I'm wrong since I have had a chance to try it out yet) which should make you job much easier since reading and writing footprint libraries is already done and your guaranteed to get the same formatting. Using your own parser and formatter means you will always be trying to keep up with the changes in KiCad.



References