Command line PCB gerber export fix and improvement.

The --board-plot-params argument was never parsed so it was always ignored.

[ADDED] A '--no-protel-ext' option to allow plotting gerbers with the KiCad
        file extension (gbr) instead of the Protel gerber file extensions.

(cherry picked from commit 4e79d1ecdd)
This commit is contained in:
Wayne Stambaugh 2023-06-16 07:13:45 -04:00
parent c37332bdb3
commit 285f8a0e59
5 changed files with 23 additions and 4 deletions

View File

@ -40,6 +40,7 @@ public:
m_useX2Format( true ),
m_disableApertureMacros( false ),
m_useAuxOrigin( false ),
m_useProtelFileExtension( true ),
m_precision( 5 ),
m_printMaskLayer()
{
@ -61,6 +62,7 @@ public:
bool m_useX2Format;
bool m_disableApertureMacros;
bool m_useAuxOrigin;
bool m_useProtelFileExtension;
int m_precision;

View File

@ -80,6 +80,11 @@ CLI::EXPORT_PCB_GERBER_COMMAND::EXPORT_PCB_GERBER_COMMAND( const std::string& aN
.help( UTF8STDSTR( _( "Precision of gerber coordinates, valid options: 5 or 6" ) ) )
.scan<'i', int>()
.default_value( 6 );
m_argParser.add_argument( ARG_NO_PROTEL_EXTENSION )
.help( UTF8STDSTR( _( "Use KiCad gerber file extension" ) ) )
.implicit_value( true )
.default_value( false );
}
@ -101,6 +106,7 @@ int CLI::EXPORT_PCB_GERBER_COMMAND::populateJob( JOB_EXPORT_PCB_GERBER* aJob )
aJob->m_includeNetlistAttributes = !m_argParser.get<bool>( ARG_NO_NETLIST );
aJob->m_useX2Format = !m_argParser.get<bool>( ARG_NO_X2 );
aJob->m_useAuxOrigin = m_argParser.get<bool>( ARG_USE_DRILL_FILE_ORIGIN );
aJob->m_useProtelFileExtension = !m_argParser.get<bool>( ARG_NO_PROTEL_EXTENSION );
aJob->m_precision = m_argParser.get<int>( ARG_PRECISION );
aJob->m_printMaskLayer = m_selectedLayers;
@ -123,12 +129,14 @@ int CLI::EXPORT_PCB_GERBER_COMMAND::populateJob( JOB_EXPORT_PCB_GERBER* aJob )
int CLI::EXPORT_PCB_GERBER_COMMAND::doPerform( KIWAY& aKiway )
{
int exitCode = EXPORT_PCB_BASE_COMMAND::doPerform( aKiway );
if( exitCode != EXIT_CODES::OK )
return exitCode;
std::unique_ptr<JOB_EXPORT_PCB_GERBER> gerberJob( new JOB_EXPORT_PCB_GERBER( true ) );
exitCode = populateJob( gerberJob.get() );
if( exitCode != EXIT_CODES::OK )
return exitCode;

View File

@ -33,6 +33,7 @@ namespace CLI
#define ARG_DISABLE_APERTURE_MACROS "--disable-aperture-macros"
#define ARG_USE_DRILL_FILE_ORIGIN "--use-drill-file-origin"
#define ARG_PRECISION "--precision"
#define ARG_NO_PROTEL_EXTENSION "--no-protel-ext"
class EXPORT_PCB_GERBER_COMMAND : public EXPORT_PCB_BASE_COMMAND
{

View File

@ -33,6 +33,7 @@
#define ARG_COMMON_LAYERS "--common-layers"
#define ARG_USE_BOARD_PLOT_PARAMS "--board-plot-params"
CLI::EXPORT_PCB_GERBERS_COMMAND::EXPORT_PCB_GERBERS_COMMAND() :
EXPORT_PCB_GERBER_COMMAND( "gerbers" )
{
@ -54,21 +55,24 @@ CLI::EXPORT_PCB_GERBERS_COMMAND::EXPORT_PCB_GERBERS_COMMAND() :
int CLI::EXPORT_PCB_GERBERS_COMMAND::doPerform( KIWAY& aKiway )
{
int exitCode = EXPORT_PCB_BASE_COMMAND::doPerform( aKiway );
if( exitCode != EXIT_CODES::OK )
return exitCode;
std::unique_ptr<JOB_EXPORT_PCB_GERBERS> gerberJob( new JOB_EXPORT_PCB_GERBERS( true ) );
exitCode = populateJob( gerberJob.get() );
if( exitCode != EXIT_CODES::OK )
return exitCode;
wxString layers = FROM_UTF8( m_argParser.get<std::string>( ARG_COMMON_LAYERS ).c_str() );
gerberJob->m_layersIncludeOnAll =
convertLayerStringList( layers, gerberJob->m_layersIncludeOnAllSet );
gerberJob->m_useBoardPlotParams = m_argParser.get<bool>( ARG_USE_BOARD_PLOT_PARAMS );
LOCALE_IO dummy;
exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, gerberJob.get() );
return exitCode;
}
}

View File

@ -313,8 +313,6 @@ int PCBNEW_JOBS_HANDLER::JobExportGerbers( JOB* aJob )
// Pick the basename from the board file
wxFileName fn( brd->GetFileName() );
PCB_LAYER_ID layer = *seq;
fileExt = GetGerberProtelExtension( layer );
PCB_PLOT_PARAMS plotOpts;
if( aGerberJob->m_useBoardPlotParams )
@ -322,6 +320,11 @@ int PCBNEW_JOBS_HANDLER::JobExportGerbers( JOB* aJob )
else
populateGerberPlotOptionsFromJob( plotOpts, aGerberJob );
if( plotOpts.GetUseGerberProtelExtensions() )
fileExt = GetGerberProtelExtension( layer );
else
fileExt = GerberFileExtension;
BuildPlotFileName( &fn, aGerberJob->m_outputFile, brd->GetLayerName( layer ), fileExt );
wxString fullname = fn.GetFullName();
@ -350,6 +353,7 @@ int PCBNEW_JOBS_HANDLER::JobExportGerbers( JOB* aJob )
}
wxFileName fn( aGerberJob->m_filename );
// Build gerber job file from basename
BuildPlotFileName( &fn, aGerberJob->m_outputFile, wxT( "job" ), GerberJobFileExtension );
jobfile_writer.CreateJobFile( fn.GetFullPath() );
@ -376,7 +380,7 @@ void PCBNEW_JOBS_HANDLER::populateGerberPlotOptionsFromJob( PCB_PLOT_PARAMS&
aPlotOpts.SetUseGerberX2format( aJob->m_useX2Format );
aPlotOpts.SetIncludeGerberNetlistInfo( aJob->m_includeNetlistAttributes );
aPlotOpts.SetUseAuxOrigin( aJob->m_useAuxOrigin );
aPlotOpts.SetUseGerberProtelExtensions( aJob->m_useProtelFileExtension );
aPlotOpts.SetGerberPrecision( aJob->m_precision );
}