On 10/19/2012 02:24 PM, Miguel Angel Ajo Pelayo wrote:
> Of course, I will be very happy to help on that, if you point me to the "lib 
> table" branch.

This new branch should not be needed, since the lib table is not needed for 
this script. 
The plugin types are supplied explicitly in the script as you have done.

I was not certain you were honoring the plugin type, but now see that you are 
with the
call to IO_MGR.PluginFind( plugin_Type ).


Can the efficiency of your loop be improved if we keep the two plugins 
instantiated?

See below



>
> The needed functions are here: 
> http://bazaar.launchpad.net/~kicad-testing-committers/kicad/testing/view/head:/pcbnew/scripting/module.i
> <http://bazaar.launchpad.net/%7Ekicad-testing-committers/kicad/testing/view/head:/pcbnew/scripting/module.i>
>  
>
> def GetPluginForPath(lpath):
>         return IO_MGR.PluginFind(IO_MGR.LEGACY)
>       
> def FootprintEnumerate(lpath):
>         plug = GetPluginForPath(lpath)
>         return plug.FootprintEnumerate(lpath)
>       
> def FootprintLoad(lpath,name):
>         plug = GetPluginForPath(lpath)
>         return plug.FootprintLoad(lpath,name)
>       
> def FootprintSave(lpath,module):
>       plug = GetPluginForPath(lpath)
>         return plug.FootprintSave(lpath,module)
>       
> def FootprintDelete(lpath,name):
>         plug = GetPluginForPath(lpath)
>         plug.FootprintDelete(lpath,name)
>       
> def FootprintLibCreate(lpath):
>         plug = GetPluginForPath(lpath)
>         plug.FootprintLibCreate(lpath)
>       
> def FootprintLibDelete(lpath):
>         plug = GetPluginForPath(lpath)
>         plug.FootprintLibDelete(lpath)
>       
> def FootprintIsWritable(lpath):
>         plug = GetPluginForPath(lpath)
>         plug.FootprintLibIsWritable(lpath)
>   
>     
> and they should be available from pcbnew.* :
>
> it must be something like (totally untested):
>
> import pcbnew

old = argv[1]    (my python knowledge is rusty)
new = argv[2]

legacy = IO_MGR.PluginFind(IO_MGR.LEGACY)

kicad = IO_MGR.PluginFind(IO_MGR.KICAD)


>
> list_of_parts = pcbnew.FootprintEnumerate("file.mod") 
>
> for part_id in list_of_parts:
>     module = FootprintLoad("file.mod",part_id)
>     FootprintSave("new_path",part_id)

list_of_parts = legacy.FootprintEnumerate("file.mod")

for part_id in list_of_parts:
      module = legacy.FootprintLoad( old, part_id )
     kicad.FootprintSave( new, module )



>
>
> problems will arise, and bugs will need to be hunted :-)
>
> Greetings :-)
>
>
> 2012/10/19 Dick Hollenbeck <d...@softplc.com <mailto:d...@softplc.com>>
>
>     Hi Miguel,
>
>     I would like to be able to instantiate to PLUGINs simultaneously in a 
> script, one of
>     type
>     LEGACY, and the second of type KICAD.
>
>     Then I would like to copy all the footprints from one plugin to the 
> other, thereby
>     doing a
>     conversion of the entire library behind the LEGACY plugin into the 
> library behind the
>     KICAD plugin.
>
>     Is this kind of script fu something you could help us with?
>
>     Maybe it could take two "library paths" on the command line, old and new.
>
>     FYI, a "library path" in the context of the new KICAD format is now a 
> directory,
>     whereas a
>     "library path" in the context of the LEGACY plugin is an actual *.mod 
> file, but I think
>     the API hides this abstractly.
>
>
>     Thanks for any help you can offer,
>
>     Dick
>
>
>     P.S. Wayne and I are currently collaborating on the branch which is being 
> used to
>     add the
>     "lib table" support.  So the time at which this script could be very 
> useful is
>     approaching.  I envision running it one time on all the package supplied 
> footprint
>     libraries, and that may be the end of its utility for the most part.
>
>
>
>
>
>
>
>     _______________________________________________
>     Mailing list: https://launchpad.net/~kicad-developers
>     <https://launchpad.net/%7Ekicad-developers>
>     Post to     : kicad-developers@lists.launchpad.net
>     <mailto:kicad-developers@lists.launchpad.net>
>     Unsubscribe : https://launchpad.net/~kicad-developers
>     <https://launchpad.net/%7Ekicad-developers>
>     More help   : https://help.launchpad.net/ListHelp
>
>
>
>
> -- 
>
> Miguel Angel Ajo Pelayo
> http://www.nbee.es
> +34 636 52 25 69
> skype: ajoajoajo


_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to