7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-19 18:51:40 +00:00

Gerber and drl files (& drl filenames): fix issues due to layer renumbering.

This commit is contained in:
jean-pierre charras 2024-10-14 17:53:38 +02:00
parent b092675171
commit a4292ea516
2 changed files with 21 additions and 5 deletions

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2017 Jean_Pierre Charras <jp.charras at wanadoo.fr>
* Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* 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;

View File

@ -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;