You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3 KiB

  1. #!/usr/bin/python
  2. # Test a basic back to back FootprintLoad() of a single footprint, and FootprintEnumerate()
  3. # 1) Build target _pcbnew after enabling scripting in cmake.
  4. # $ make _pcbnew
  5. # 2) Changed dir to pcbnew
  6. # $ cd pcbnew
  7. # $ pwd
  8. # build/pcbnew
  9. # 3) Entered following command line, script takes to arguments: library_path [footprint_name]
  10. # $ PYTHONPATH=. <path_to>/test_plugin.py https://github.com/liftoff-sr/pretty_footprints [100-LQFP]
  11. from __future__ import print_function
  12. from pcbnew import *
  13. import sys
  14. if len( sys.argv ) < 2 :
  15. print( "usage: script <library_path> [<footprint_name>]" )
  16. sys.exit(1)
  17. src_libpath = sys.argv[1]
  18. src_type = IO_MGR.GuessPluginTypeFromLibPath( src_libpath );
  19. src_plugin = IO_MGR.PluginFind( src_type )
  20. if len( sys.argv ) == 2:
  21. list_of_footprints = src_plugin.FootprintEnumerate( src_libpath )
  22. for fp in list_of_footprints:
  23. print( fp )
  24. elif len( sys.argv ) == 3:
  25. # I had some concerns about back to back reads, this verifies it is no problem:
  26. module = src_plugin.FootprintLoad( src_libpath, sys.argv[2] )
  27. if not module:
  28. print( "1st try: module", sys.argv[2], "not found" )
  29. module = src_plugin.FootprintLoad( src_libpath, sys.argv[2] )
  30. if not module:
  31. print( "2nd try: module", sys.argv[2], "not found" )
  32. print( module )