← Back to team overview

kicad-developers team mailing list archive

[PATCH] Added option in drill file generation to generate PTH and NPTH holes in the same file

 

Hi,

Attached is a patch that adds an option in the drill generation dialog to generate both PTH and NPTH holes in the same file.

The current setup calls BuildHolesList() twice, once with NPTH only and once with PTH only. I changed it to essentially move all holes to PTH if the flag is set (so the second invocation will return empty hole set, so that the -NPTH.drl file won't be created).

This is useful because some fabs cannot do NPTH holes, and would only accept 1 .drl file.

Thanks!
Matthew
=== modified file 'pcbnew/dialogs/dialog_gendrill.cpp'
--- pcbnew/dialogs/dialog_gendrill.cpp	2012-12-06 21:53:00 +0000
+++ pcbnew/dialogs/dialog_gendrill.cpp	2013-01-10 08:07:09 +0000
@@ -46,6 +46,7 @@
 #define PrecisionKey            wxT( "DrilltPrecisionOpt" )
 #define MirrorKey               wxT( "DrillMirrorYOpt" )
 #define MinimalHeaderKey        wxT( "DrillMinHeader" )
+#define MergePTHNPTHKey		  wxT( "DrillMergePTHNPTH" )
 #define UnitDrillInchKey        wxT( "DrillUnit" )
 #define DrillOriginIsAuxAxisKey wxT( "DrillAuxAxis" )
 #define DrillMapFileTypeKey     wxT( "DrillMapFileType" )
@@ -87,6 +88,7 @@
 int DIALOG_GENDRILL::m_ZerosFormat     = EXCELLON_WRITER::DECIMAL_FORMAT;
 bool DIALOG_GENDRILL::m_MinimalHeader   = false;
 bool DIALOG_GENDRILL::m_Mirror = false;
+bool DIALOG_GENDRILL::m_Merge_PTH_NPTH = false;
 bool DIALOG_GENDRILL::m_DrillOriginIsAuxAxis = false;
 int DIALOG_GENDRILL::m_mapFileType = 1;
 
@@ -101,6 +103,7 @@
 {
     m_config->Read( ZerosFormatKey, &m_ZerosFormat );
     m_config->Read( MirrorKey, &m_Mirror );
+    m_config->Read( MergePTHNPTHKey, &m_Merge_PTH_NPTH );
     m_config->Read( MinimalHeaderKey, &m_MinimalHeader );
     m_config->Read( UnitDrillInchKey, &m_UnitDrillIsInch );
     m_config->Read( DrillOriginIsAuxAxisKey, &m_DrillOriginIsAuxAxis );
@@ -123,6 +126,7 @@
         m_Choice_Drill_Offset->SetSelection( 1 );
 
     m_Check_Mirror->SetValue( m_Mirror );
+    m_Check_Merge_PTH_NPTH->SetValue( m_Merge_PTH_NPTH );
     m_Choice_Drill_Map->SetSelection( m_mapFileType );
     m_ViaDrillValue->SetLabel( _( "Use Netclasses values" ) );
     m_MicroViaDrillValue->SetLabel( _( "Use Netclasses values" ) );
@@ -212,6 +216,7 @@
     m_config->Write( ZerosFormatKey, m_ZerosFormat );
     m_config->Write( MirrorKey, m_Mirror );
     m_config->Write( MinimalHeaderKey, m_MinimalHeader );
+    m_config->Write( MergePTHNPTHKey, m_Merge_PTH_NPTH );
     m_config->Write( UnitDrillInchKey, m_UnitDrillIsInch );
     m_config->Write( DrillOriginIsAuxAxisKey, m_DrillOriginIsAuxAxis );
     m_config->Write( DrillMapFileTypeKey, m_mapFileType );
@@ -314,6 +319,7 @@
     m_UnitDrillIsInch = (m_Choice_Unit->GetSelection() == 0) ? false : true;
     m_MinimalHeader   = m_Check_Minimal->IsChecked();
     m_Mirror = m_Check_Mirror->IsChecked();
+    m_Merge_PTH_NPTH = m_Check_Merge_PTH_NPTH->IsChecked();
     m_ZerosFormat = m_Choice_Zeros_Format->GetSelection();
     m_DrillOriginIsAuxAxis = m_Choice_Drill_Offset->GetSelection();
 
@@ -368,14 +374,14 @@
     excellonWriter.SetFormat( !m_UnitDrillIsInch,
                               (EXCELLON_WRITER::zeros_fmt) m_ZerosFormat,
                               m_Precision.m_lhs, m_Precision.m_rhs );
-    excellonWriter.SetOptions( m_Mirror, m_MinimalHeader, m_FileDrillOffset );
+    excellonWriter.SetOptions( m_Mirror, m_MinimalHeader, m_FileDrillOffset, m_Merge_PTH_NPTH );
 
     wxFileName fn;
 
     for( ; ; )
     {
         excellonWriter.BuildHolesList( layer1, layer2,
-                          gen_through_holes ? false : true, gen_NPTH_holes );
+                          gen_through_holes ? false : true, gen_NPTH_holes, m_Merge_PTH_NPTH );
 
         if( excellonWriter.GetHolesCount() > 0 ) // has holes?
         {
@@ -510,7 +516,7 @@
     excellonWriter.SetFormat( !m_UnitDrillIsInch,
                               (EXCELLON_WRITER::zeros_fmt) m_ZerosFormat,
                               m_Precision.m_lhs, m_Precision.m_rhs );
-    excellonWriter.SetOptions( m_Mirror, m_MinimalHeader, m_FileDrillOffset );
+    excellonWriter.SetOptions( m_Mirror, m_MinimalHeader, m_FileDrillOffset, m_Merge_PTH_NPTH );
 
     bool success = excellonWriter.GenDrillReportFile( dlg.GetPath() );
 

=== modified file 'pcbnew/dialogs/dialog_gendrill.h'
--- pcbnew/dialogs/dialog_gendrill.h	2012-10-05 19:04:17 +0000
+++ pcbnew/dialogs/dialog_gendrill.h	2013-01-10 08:06:27 +0000
@@ -41,6 +41,7 @@
     static int       m_ZerosFormat;
     static bool      m_MinimalHeader;
     static bool      m_Mirror;
+    static bool	 m_Merge_PTH_NPTH;
     static bool      m_DrillOriginIsAuxAxis; /* Axis selection (main / auxiliary)
                                               *  for drill origin coordinates */
     DRILL_PRECISION  m_Precision;           // Selected precision for drill files

=== modified file 'pcbnew/dialogs/dialog_gendrill_base.cpp'
--- pcbnew/dialogs/dialog_gendrill_base.cpp	2012-10-13 18:54:33 +0000
+++ pcbnew/dialogs/dialog_gendrill_base.cpp	2013-01-10 07:40:14 +0000
@@ -86,7 +86,9 @@
 	
 	m_Check_Minimal = new wxCheckBox( this, wxID_ANY, _("Minimal header"), wxDefaultPosition, wxDefaultSize, 0 );
 	sbOptSizer->Add( m_Check_Minimal, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
-	
+		
+	m_Check_Merge_PTH_NPTH = new wxCheckBox( this, wxID_ANY, _("Merge PTH and NPTH holes into one file"), wxDefaultPosition, wxDefaultSize, 0 );
+	sbOptSizer->Add( m_Check_Merge_PTH_NPTH, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
 	
 	bMiddleBoxSizer->Add( sbOptSizer, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
 	

=== modified file 'pcbnew/dialogs/dialog_gendrill_base.h'
--- pcbnew/dialogs/dialog_gendrill_base.h	2012-10-05 19:04:17 +0000
+++ pcbnew/dialogs/dialog_gendrill_base.h	2013-01-10 07:36:16 +0000
@@ -46,6 +46,7 @@
 		wxRadioBox* m_Choice_Drill_Map;
 		wxCheckBox* m_Check_Mirror;
 		wxCheckBox* m_Check_Minimal;
+		wxCheckBox* m_Check_Merge_PTH_NPTH;
 		wxRadioBox* m_Choice_Drill_Offset;
 		wxStaticBoxSizer* m_DefaultViasDrillSizer;
 		wxStaticText* m_ViaDrillValue;

=== modified file 'pcbnew/gen_drill_report_files.cpp'
--- pcbnew/gen_drill_report_files.cpp	2012-10-13 18:54:33 +0000
+++ pcbnew/gen_drill_report_files.cpp	2013-01-10 08:09:30 +0000
@@ -359,7 +359,7 @@
     for( ; ; )
     {
         BuildHolesList( layer1, layer2,
-                          gen_through_holes ? false : true, gen_NPTH_holes );
+                          gen_through_holes ? false : true, gen_NPTH_holes, false );
 
         totalHoleCount = 0;
 

=== modified file 'pcbnew/gendrill_Excellon_writer.cpp'
--- pcbnew/gendrill_Excellon_writer.cpp	2012-10-05 12:25:12 +0000
+++ pcbnew/gendrill_Excellon_writer.cpp	2013-01-10 08:04:25 +0000
@@ -441,11 +441,13 @@
  * param aGenerateNPTH_list :
  *       true to create NPTH only list (with no plated holes)
  *       false to created plated holes list (with no NPTH )
+ * param aMergePTHNPTH : if true, merge PTH and NPTH holes into one file by treating all holes as PTH
  */
 void EXCELLON_WRITER::BuildHolesList( int aFirstLayer,
                                       int aLastLayer,
                                       bool aExcludeThroughHoles,
-                                      bool aGenerateNPTH_list )
+                                      bool aGenerateNPTH_list,
+                                      bool aMergePTHNPTH )
 {
     HOLE_INFO new_hole;
     int       hole_value;
@@ -458,6 +460,11 @@
         if( aFirstLayer > aLastLayer )
             EXCHG( aFirstLayer, aLastLayer );
     }
+    
+    if ( aGenerateNPTH_list && aMergePTHNPTH )
+    {
+        return;
+    }
 
     /* build hole list for vias
     */
@@ -506,7 +513,7 @@
             // Read and analyse pads
             for( D_PAD* pad = module->m_Pads;  pad;  pad = pad->Next() )
             {
-                if( ! aGenerateNPTH_list && pad->GetAttribute() == PAD_HOLE_NOT_PLATED )
+                if( ! aGenerateNPTH_list && pad->GetAttribute() == PAD_HOLE_NOT_PLATED && ! aMergePTHNPTH )
                     continue;
 
                 if( aGenerateNPTH_list && pad->GetAttribute() != PAD_HOLE_NOT_PLATED )

=== modified file 'pcbnew/gendrill_Excellon_writer.h'
--- pcbnew/gendrill_Excellon_writer.h	2012-12-18 13:54:44 +0000
+++ pcbnew/gendrill_Excellon_writer.h	2013-01-10 08:07:57 +0000
@@ -135,6 +135,7 @@
                                                         // (i.e inches or mm)
     bool                     m_mirror;
     wxPoint                  m_offset;                  // Drill offset ooordinates
+    bool				    m_mergePTHNPTH;
     std::vector<HOLE_INFO>   m_holeListBuffer;          // Buffer containing holes
     std::vector<DRILL_TOOL>  m_toolListBuffer;          // Buffer containing tools
 
@@ -146,6 +147,7 @@
         m_conversionUnits = 0.0001;
         m_unitsDecimal    = false;
         m_mirror = false;
+        m_mergePTHNPTH = false;
         m_minimalHeader = false;
     }
 
@@ -177,11 +179,12 @@
      * @param aMinimalHeader = true to use a minimal header (no comments, no info)
      * @param aOffset = drill coordinates offset
      */
-    void SetOptions( bool aMirror, bool aMinimalHeader, wxPoint aOffset )
+    void SetOptions( bool aMirror, bool aMinimalHeader, wxPoint aOffset, bool aMergePTHNPTH )
     {
         m_mirror = aMirror;
         m_offset = aOffset;
         m_minimalHeader = aMinimalHeader;
+        m_mergePTHNPTH = aMergePTHNPTH;
     }
 
     /**
@@ -199,7 +202,8 @@
      */
     void BuildHolesList( int aFirstLayer, int aLastLayer,
                            bool aExcludeThroughHoles,
-                           bool aGenerateNPTH_list );
+                           bool aGenerateNPTH_list,
+                           bool aMergePTHNPTH );
 
     int  GetHolesCount() const { return m_holeListBuffer.size(); }
 


Follow ups