diff options
author | saurabhb17 | 2020-02-26 16:37:17 +0530 |
---|---|---|
committer | GitHub | 2020-02-26 16:37:17 +0530 |
commit | 07a8c86216b6b1f694b136ec64c281d62941952e (patch) | |
tree | ad18839d8b4eb1f13419d07878cc4ec4c9b70032 /scripts/lib_convert.py | |
parent | e255d0622297488c1c52755be670733418c994cf (diff) | |
parent | 1fa449fed953fa11f6bd0ea82cc2d3b115ee0781 (diff) | |
download | KiCad-eSim-07a8c86216b6b1f694b136ec64c281d62941952e.tar.gz KiCad-eSim-07a8c86216b6b1f694b136ec64c281d62941952e.tar.bz2 KiCad-eSim-07a8c86216b6b1f694b136ec64c281d62941952e.zip |
Merge pull request #2 from saurabhb17/develop
Remaining files transfered
Diffstat (limited to 'scripts/lib_convert.py')
-rwxr-xr-x | scripts/lib_convert.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/scripts/lib_convert.py b/scripts/lib_convert.py new file mode 100755 index 0000000..18abc72 --- /dev/null +++ b/scripts/lib_convert.py @@ -0,0 +1,51 @@ +#!/usr/bin/python + +# Convert a footprint library from one format to another, e.g. legacy to pretty. + +# 1) Build target _pcbnew after enabling scripting in cmake. +# $ make _pcbnew + +# 2) Changed dir to pcbnew +# $ cd pcbnew +# $ pwd +# build/pcbnew + +# 3) Entered following command line, script takes to arguments: oldLibPath & newLibPath +# $ PYTHONPATH=. <path_to>/lib_convert.py /usr/local/share/kicad/modules/smd_dil.mod /tmp/smd_dil.pretty + +# 4) inspect one footprint found in new librarypath /tmp/smd_dil.pretty +# $ less /tmp/smd_dil.pretty/msoic-10.kicad_mod + + +from __future__ import print_function +from pcbnew import * +import sys + +if len( sys.argv ) < 3 : + print( "usage: script srcLibraryPath dstLibraryPath" ) + sys.exit(1) + + +src_libpath = sys.argv[1] +dst_libpath = sys.argv[2] + + +src_type = IO_MGR.GuessPluginTypeFromLibPath( src_libpath ); +dst_type = IO_MGR.GuessPluginTypeFromLibPath( dst_libpath ); + +src_plugin = IO_MGR.PluginFind( src_type ) +dst_plugin = IO_MGR.PluginFind( dst_type ) + +try: + dst_plugin.FootprintLibDelete( dst_libpath ) +except: + None # ignore, new may not exist if first run + +dst_plugin.FootprintLibCreate( dst_libpath ) + +list_of_parts = src_plugin.FootprintEnumerate( src_libpath ) + +for part_id in list_of_parts: + module = src_plugin.FootprintLoad( src_libpath, part_id ) + dst_plugin.FootprintSave( dst_libpath, module ) + |