← Back to team overview

kicad-developers team mailing list archive

PLUGIN i.e. library conversion script


The attached script converts footprints from one library type to another.  The PLUGIN type
defines the library format.

Most any PLUGIN type may be used as a source.  Only writable PLUGINsmay be used as a

You currently have to edit the plugin types in the script.  (In my last usage of it, I
converted EAGLE to KICADfor testing the EAGLE_PLUGIN.)

Some plugins are read only, sotrying to write to that plugin should not succeed.

Now that the EAGLE_PLUGIN::FootprintLoad() and FootprintEnumerate() functions are
implemented, this brings access to quite a large set of footprints, if you wanted to jump
the gun and convert libraries. 

If you wait for fp_lib_table support, you will not have to convert.

We may want to commit a script like this to the tree somewhere.  Developers may find it
helpful for testing.


from __future__ import print_function
from pcbnew import *
import sys

if len( sys.argv ) < 3 :
    print( "usage: script oldLibraryPath newLibraryPath" )

# 2 libraryPaths.  A lib_path is either a file or directory depending on
# plugin type.

src_lib_path = sys.argv[1]
dst_lib_path = sys.argv[2]

src_plugin = IO_MGR.PluginFind( IO_MGR.EAGLE )
dst_plugin  = IO_MGR.PluginFind( IO_MGR.KICAD )

    dst_plugin.FootprintLibDelete( dst_lib_path )
    None    # ignore, dst_lib_path may not exist if first run

dst_plugin.FootprintLibCreate( dst_lib_path )

list_of_parts = src_plugin.FootprintEnumerate( src_lib_path )

for part_id in list_of_parts:
    module = src_plugin.FootprintLoad( src_lib_path, part_id )
    dst_plugin.FootprintSave( dst_lib_path, module )