diff --git a/pcbnew/exporters/gendrill_file_writer_base.cpp b/pcbnew/exporters/gendrill_file_writer_base.cpp index d8fca875d6..36b58feb9d 100644 --- a/pcbnew/exporters/gendrill_file_writer_base.cpp +++ b/pcbnew/exporters/gendrill_file_writer_base.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2017 Jean_Pierre Charras * Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -252,7 +252,11 @@ const std::string GENDRILL_WRITER_BASE::layerName( PCB_LAYER_ID aLayer ) const case B_Cu: return "back"; default: - return StrPrintf( "in%d", aLayer ); + { + // aLayer use even values, and the first internal layer (In1) is B_Cu + 2. + int ly_id = ( aLayer - B_Cu ) / 2; + return StrPrintf( "in%d", ly_id ); + } } } @@ -386,12 +390,18 @@ const wxString GENDRILL_WRITER_BASE::BuildFileFunctionAttributeString( // In Gerber files, layers num are 1 to copper layer count instead of F_Cu to B_Cu // (0 to copper layer count-1) // Note also for a n copper layers board, gerber layers num are 1 ... n - layer1 += 1; + // + // Copper layers use even values, so the layer id in file is + // (Copper layer id) /2 + 1 if layer is not B_Cu + if( layer1 == F_Cu ) + layer1 = 1; + else + layer1 = ( ( layer1 - B_Cu ) / 2 ) + 1; if( layer2 == B_Cu ) layer2 = m_pcb->GetCopperLayerCount(); else - layer2 += 1; + layer2 = ( ( layer2 - B_Cu ) / 2) + 1; text << layer1 << wxT( "," ) << layer2; diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp index 477f2d320a..75ad1dc76e 100644 --- a/pcbnew/pcbplot.cpp +++ b/pcbnew/pcbplot.cpp @@ -83,6 +83,7 @@ const wxString GetGerberFileFunctionAttribute( const BOARD* aBoard, int aLayer ) { wxString attrib; + switch( aLayer ) { case F_Adhes: @@ -160,7 +161,12 @@ const wxString GetGerberFileFunctionAttribute( const BOARD* aBoard, int aLayer ) default: if( IsCopperLayer( aLayer ) ) - attrib.Printf( wxT( "Copper,L%d,Inr" ), aLayer+1 ); + { + // aLayer use even values, and the first internal layer + // is B_Cu + 2. And in gerber file, layer id is 2 (1 is F_Cu) + int ly_id = ( ( aLayer - B_Cu ) / 2 ) + 1; + attrib.Printf( wxT( "Copper,L%d,Inr" ), ly_id ); + } else attrib.Printf( wxT( "Other,User" ), aLayer+1 ); break;