3
# Convert a footprint library from one format to another, e.g. legacy to pretty.
5
# 1) Build target _pcbnew after enabling scripting in cmake.
8
# 2) Changed dir to pcbnew
13
# 3) Entered following command line, script takes to arguments: oldLibPath & newLibPath
14
# $ PYTHONPATH=. <path_to>/lib_convert.py /usr/local/share/kicad/modules/smd_dil.mod /tmp/smd_dil.pretty
16
# 4) inspect one footprint found in new librarypath /tmp/smd_dil
17
# $ less /tmp/smd_dil/msoic-10.kicad_mod
20
from __future__ import print_function
24
if len( sys.argv ) < 3 :
25
print( "usage: script srcLibraryPath dstLibraryPath" )
29
src_libpath = sys.argv[1]
30
dst_libpath = sys.argv[2]
33
src_type = IO_MGR.GuessPluginTypeFromLibPath( src_libpath );
34
dst_type = IO_MGR.GuessPluginTypeFromLibPath( dst_libpath );
36
src_plugin = IO_MGR.PluginFind( src_type )
37
dst_plugin = IO_MGR.PluginFind( dst_type )
40
dst_plugin.FootprintLibDelete( dst_libpath )
42
None # ignore, new may not exist if first run
44
dst_plugin.FootprintLibCreate( dst_libpath )
46
list_of_parts = src_plugin.FootprintEnumerate( src_libpath )
48
for part_id in list_of_parts:
49
module = src_plugin.FootprintLoad( src_libpath, part_id )
50
dst_plugin.FootprintSave( dst_libpath, module )