Source

PCBmodE / pcbmode.py

Diff from to

pcbmode.py

                       action='store_true', dest='routing', default=False,
                       help="Extract routing from the 'copper' layer of an SVG file")
      
-    argp.add_argument('-g', '--gerberise',
-                      action='store_true', dest='gerberise', default=False,
-                      help='Generate Gerber files for all layers')
+    argp.add_argument('-fab', '--fab', nargs='?',
+                      dest='fab', default=False,
+                      help='Generate manufacturing files (Gerbers, Excellon, etc.)')
 
-    argp.add_argument('-e', '--make-excellon',
-                      action='store_true', dest='excellon', default=False,
-                      help='Generate and Excellon drill file')
-     
     argp.add_argument('-p', '--make-pngs',
                       action='store_true', dest='pngs', default=False,
                       help='Generate PNGs for the board and layers (requires Inkscape)')
+
+#    argp.add_argument('-z', '--zip',
+#                      action='store_true', dest='zip', default=False,
+#                      help='Zip manufacturing files')    
         
     return argp
 
     if cmdline_args.make is True:
         print "-- creating board"
         board.create_board(cfg) 
+
     
-    if cmdline_args.gerberise is True:
-        print "-- gerberising"
-        gerber.gerberise(cfg)
-     
+    if cmdline_args.fab is not False:
+        if cmdline_args.fab is None:
+            manufacturer = 'default'
+        else:
+            manufacturer = cmdline_args.fab.lower()
+
+        print "-- creating Gerbers"
+        print "files:",
+        gerber_filenames = gerber.gerberise(cfg, manufacturer)
+        print
+        print "-- creating drill file(s)"
+        print "files:",
+        drill_filenames = excellon.make_excellon(cfg, manufacturer)
+        print
+
+        filenames = gerber_filenames + drill_filenames
+
+        # create a readme file
+        readme = open(os.path.join(cfg['base_dir'],
+                                    cfg['pcbmode']['locations']['build'], 
+                                    'production', 'README.txt'), 'w')
+
+        readme.write("The following files are included in this archive:\n")
+        for f in filenames:
+            readme.write("%s\n" % os.path.basename(f))
+        readme.write("\n")
+        readme.write("Please refer to the docoumentation Gerber file for manufacturing instructions.")
+        readme.write("\n")
+        readme.close()
+
+        
+#        if cmdline_args.zip is True:
+# 
+#            filenames = gerber_filenames + drill_filenames
+# 
+#            board_name = cfg['board_name']
+#            board_revision = cfg['board']['meta'].get('board_revision') or 'A'
+#            base_dir = os.path.join(cfg['base_dir'], 
+#                                    cfg['pcbmode']['locations']['build'], 
+#                                    'production')
+#            base_name = "%s_rev_%s" % (board_name, board_revision)
+# 
+#            zip_name = base_name + '.zip'
+# 
+#            print "-- creating zip of manufacturing files"
+#            utils.zip_files(base_dir, zip_name, filenames)
+
+
+
     if cmdline_args.pngs is True:
         print "-- creating PNGs"
         utils.create_pngs(cfg)
      
-    if cmdline_args.excellon is True:
-        print "-- generating Excellon drill file"
-        excellon.make_excellon(cfg)
-     
+    
     if cmdline_args.bom is True:
         print "-- creating BOM (not implemented yet!)"
         pass