Plot Gerber, StartPlotBoard(): display a error message if the layer is not valid.

It can happens in Python scripts, when the layer is not set when starting plot,
and therefore the Gerber file header is incorrect.
This commit is contained in:
jean-pierre charras 2022-09-30 18:15:56 +02:00
parent 6a6ef9b1f4
commit a2a442a9f7
1 changed files with 9 additions and 0 deletions

View File

@ -1161,6 +1161,15 @@ PLOTTER* StartPlotBoard( BOARD *aBoard, const PCB_PLOT_PARAMS *aPlotOpts, int aL
break;
case PLOT_FORMAT::GERBER:
// For Gerber plotter, a valid board layer must be set, in order to create a valid
// Gerber header, especially the TF.FileFunction and .FilePolarity data
if( aLayer < PCBNEW_LAYER_ID_START || aLayer >= PCB_LAYER_ID_COUNT )
{
wxLogError( wxString::Format(
"Invalid board layer %d, cannot build a valid Gerber file header",
aLayer ) );
}
plotter = new GERBER_PLOTTER();
break;