9 changed files with 396 additions and 2 deletions
-
1common/CMakeLists.txt
-
38common/jobs/job_export_pcb_ipc2581.cpp
-
62common/jobs/job_export_pcb_ipc2581.h
-
1kicad/CMakeLists.txt
-
152kicad/cli/command_pcb_export_ipc2581.cpp
-
47kicad/cli/command_pcb_export_ipc2581.h
-
3kicad/kicad_cli.cpp
-
93pcbnew/pcbnew_jobs_handler.cpp
-
1pcbnew/pcbnew_jobs_handler.h
@ -0,0 +1,38 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2024 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 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 as published by the |
|||
* Free Software Foundation, either version 3 of the License, or (at your |
|||
* option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, but |
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
* General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License along |
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include <jobs/job_export_pcb_ipc2581.h>
|
|||
|
|||
JOB_EXPORT_PCB_IPC2581::JOB_EXPORT_PCB_IPC2581( bool aIsCli ) : |
|||
JOB( "ipc2581", aIsCli ), |
|||
m_filename(), |
|||
m_outputFile(), |
|||
m_drawingSheet(), |
|||
m_units( IPC2581_UNITS::MILLIMETERS ), |
|||
m_version( IPC2581_VERSION::C ), |
|||
m_precision( 3 ), |
|||
m_compress( false ), |
|||
m_colInternalId(), |
|||
m_colMfgPn(), |
|||
m_colMfg(), |
|||
m_colDistPn(), |
|||
m_colDist() |
|||
{ |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2024 Mark Roszko <mark.roszko@gmail.com> |
|||
* 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 as published by the |
|||
* Free Software Foundation, either version 3 of the License, or (at your |
|||
* option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, but |
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
* General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License along |
|||
* with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef JOB_EXPORT_PCB_IPC2581_H |
|||
#define JOB_EXPORT_PCB_IPC2581_H |
|||
|
|||
#include <kicommon.h> |
|||
#include <wx/string.h> |
|||
#include "job.h" |
|||
|
|||
class KICOMMON_API JOB_EXPORT_PCB_IPC2581 : public JOB |
|||
{ |
|||
public: |
|||
JOB_EXPORT_PCB_IPC2581( bool aIsCli ); |
|||
|
|||
enum class IPC2581_UNITS |
|||
{ |
|||
INCHES, |
|||
MILLIMETERS |
|||
}; |
|||
|
|||
enum class IPC2581_VERSION |
|||
{ |
|||
B, |
|||
C |
|||
}; |
|||
|
|||
wxString m_filename; |
|||
wxString m_outputFile; |
|||
wxString m_drawingSheet; |
|||
|
|||
IPC2581_UNITS m_units; |
|||
IPC2581_VERSION m_version; |
|||
int m_precision; |
|||
|
|||
bool m_compress; |
|||
|
|||
wxString m_colInternalId; |
|||
wxString m_colMfgPn; |
|||
wxString m_colMfg; |
|||
wxString m_colDistPn; |
|||
wxString m_colDist; |
|||
}; |
|||
|
|||
#endif |
|||
@ -0,0 +1,152 @@ |
|||
/*
|
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 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 as published by the |
|||
* Free Software Foundation, either version 3 of the License, or (at your |
|||
* option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, but |
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
* General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License along |
|||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
#include "command_pcb_export_ipc2581.h"
|
|||
#include <cli/exit_codes.h>
|
|||
#include "jobs/job_export_pcb_ipc2581.h"
|
|||
#include <kiface_base.h>
|
|||
#include <string_utils.h>
|
|||
#include <wx/crt.h>
|
|||
|
|||
#include <macros.h>
|
|||
#include <wx/tokenzr.h>
|
|||
|
|||
#include <locale_io.h>
|
|||
|
|||
#define ARG_COMPRESS "--compress"
|
|||
|
|||
#define ARG_BOM_COL_INT_ID "--bom-col-int-id"
|
|||
#define ARG_BOM_COL_MFG_PN "--bom-col-mfg-pn"
|
|||
#define ARG_BOM_COL_MFG "--bom-col-mfg"
|
|||
#define ARG_BOM_COL_DIST_PN "--bom-col-dist-pn"
|
|||
#define ARG_BOM_COL_DIST "--bom-col-dist"
|
|||
#define ARG_UNITS "--units"
|
|||
|
|||
CLI::PCB_EXPORT_IPC2581_COMMAND::PCB_EXPORT_IPC2581_COMMAND() : |
|||
PCB_EXPORT_BASE_COMMAND( "ipc2581" ) |
|||
{ |
|||
addDrawingSheetArg(); |
|||
addDefineArg(); |
|||
|
|||
m_argParser.add_description( std::string( "Export the PCB in IPC2581 format" ) ); |
|||
|
|||
m_argParser.add_argument( ARG_PRECISION ) |
|||
.help( std::string( "Precision" ) ) |
|||
.scan<'i', int>() |
|||
.default_value( 3 ) |
|||
.metavar( "PRECISION" ); |
|||
|
|||
m_argParser.add_argument( ARG_COMPRESS ) |
|||
.help( std::string( "Subtract soldermask from silkscreen" ) ) |
|||
.flag(); |
|||
|
|||
m_argParser.add_argument( ARG_VERSION ) |
|||
.default_value( std::string( "C" ) ) |
|||
.help( std::string( "IPC2581 standard version" ) ) |
|||
.choices( "B", "C" ); |
|||
|
|||
m_argParser.add_argument( ARG_UNITS ) |
|||
.default_value( std::string( "mm" ) ) |
|||
.help( std::string( "Units" ) ) |
|||
.choices( "mm", "in" ); |
|||
|
|||
m_argParser.add_argument( ARG_BOM_COL_INT_ID ) |
|||
.default_value( std::string() ) |
|||
.help( std::string( |
|||
"Name of the part field to use for the Bill of Material Internal Id Column" ) ) |
|||
.metavar( "FIELD_NAME" ); |
|||
|
|||
m_argParser.add_argument( ARG_BOM_COL_MFG_PN ) |
|||
.default_value( std::string() ) |
|||
.help( std::string( "Name of the part field to use for the Bill of " |
|||
"Material Manufacturer Part Number Column" ) ) |
|||
.metavar( "FIELD_NAME" ); |
|||
|
|||
m_argParser.add_argument( ARG_BOM_COL_MFG ) |
|||
.default_value( std::string() ) |
|||
.help( std::string( "Name of the part field to use for the Bill of " |
|||
"Material Manufacturer Column" ) ) |
|||
.metavar( "FIELD_NAME" ); |
|||
|
|||
m_argParser.add_argument( ARG_BOM_COL_DIST_PN ) |
|||
.default_value( std::string() ) |
|||
.help( std::string( "Name of the part field to use for the Bill of " |
|||
"Material Distributor Part Number Column" ) ) |
|||
.metavar( "FIELD_NAME" ); |
|||
|
|||
m_argParser.add_argument( ARG_BOM_COL_DIST ) |
|||
.default_value( std::string() ) |
|||
.help( std::string( "Name to insert into Bill of " |
|||
"Material Distributor Column" ) ) |
|||
.metavar( "FIELD_NAME" ); |
|||
|
|||
} |
|||
|
|||
|
|||
int CLI::PCB_EXPORT_IPC2581_COMMAND::doPerform( KIWAY& aKiway ) |
|||
{ |
|||
int exitCode = PCB_EXPORT_BASE_COMMAND::doPerform( aKiway ); |
|||
|
|||
if( exitCode != EXIT_CODES::OK ) |
|||
return exitCode; |
|||
|
|||
std::unique_ptr<JOB_EXPORT_PCB_IPC2581> ipc2581Job( new JOB_EXPORT_PCB_IPC2581( true ) ); |
|||
|
|||
ipc2581Job->m_filename = m_argInput; |
|||
ipc2581Job->m_outputFile = m_argOutput; |
|||
ipc2581Job->m_drawingSheet = m_argDrawingSheet; |
|||
ipc2581Job->SetVarOverrides( m_argDefineVars ); |
|||
|
|||
if( !wxFile::Exists( ipc2581Job->m_filename ) ) |
|||
{ |
|||
wxFprintf( stderr, _( "Board file does not exist or is not accessible\n" ) ); |
|||
return EXIT_CODES::ERR_INVALID_INPUT_FILE; |
|||
} |
|||
|
|||
ipc2581Job->m_compress = m_argParser.get<bool>( ARG_COMPRESS ); |
|||
ipc2581Job->m_precision = m_argParser.get<int>( ARG_PRECISION ); |
|||
|
|||
wxString version = From_UTF8( m_argParser.get<std::string>( ARG_VERSION ).c_str() ); |
|||
if( version == 'B' ) |
|||
ipc2581Job->m_version = JOB_EXPORT_PCB_IPC2581::IPC2581_VERSION::B; |
|||
else if( version == 'C' ) |
|||
ipc2581Job->m_version = JOB_EXPORT_PCB_IPC2581::IPC2581_VERSION::C; |
|||
|
|||
wxString units = From_UTF8( m_argParser.get<std::string>( ARG_UNITS ).c_str() ); |
|||
if( version == "mm" ) |
|||
ipc2581Job->m_units = JOB_EXPORT_PCB_IPC2581::IPC2581_UNITS::MILLIMETERS; |
|||
else if( version == "in" ) |
|||
ipc2581Job->m_units = JOB_EXPORT_PCB_IPC2581::IPC2581_UNITS::INCHES; |
|||
|
|||
ipc2581Job->m_colInternalId = |
|||
From_UTF8( m_argParser.get<std::string>( ARG_BOM_COL_INT_ID ).c_str() ); |
|||
ipc2581Job->m_colMfgPn = |
|||
From_UTF8( m_argParser.get<std::string>( ARG_BOM_COL_MFG_PN ).c_str() ); |
|||
ipc2581Job->m_colMfg = From_UTF8( m_argParser.get<std::string>( ARG_BOM_COL_MFG ).c_str() ); |
|||
ipc2581Job->m_colDistPn = |
|||
From_UTF8( m_argParser.get<std::string>( ARG_BOM_COL_DIST_PN ).c_str() ); |
|||
ipc2581Job->m_colDist = |
|||
From_UTF8( m_argParser.get<std::string>( ARG_BOM_COL_DIST ).c_str() ); |
|||
|
|||
LOCALE_IO dummy; |
|||
exitCode = aKiway.ProcessJob( KIWAY::FACE_PCB, ipc2581Job.get() ); |
|||
|
|||
return exitCode; |
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
/* |
|||
* This program source code file is part of KiCad, a free EDA CAD application. |
|||
* |
|||
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com> |
|||
* Copyright (C) 1992-2022 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 as published by the |
|||
* Free Software Foundation, either version 3 of the License, or (at your |
|||
* option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, but |
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
* General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU General Public License along |
|||
* with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef COMMAND_EXPORT_PCB_IPC2581_H |
|||
#define COMMAND_EXPORT_PCB_IPC2581_H |
|||
|
|||
#include "command_pcb_export_base.h" |
|||
|
|||
|
|||
namespace CLI |
|||
{ |
|||
#define ARG_NO_X2 "--no-x2" |
|||
#define ARG_NO_NETLIST "--no-netlist" |
|||
#define ARG_SUBTRACT_SOLDERMASK "--subtract-soldermask" |
|||
#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 PCB_EXPORT_IPC2581_COMMAND : public PCB_EXPORT_BASE_COMMAND |
|||
{ |
|||
public: |
|||
PCB_EXPORT_IPC2581_COMMAND(); |
|||
|
|||
protected: |
|||
int doPerform( KIWAY& aKiway ) override; |
|||
}; |
|||
} // namespace CLI |
|||
|
|||
#endif |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue