Load custom drawing sheets for pcb cli

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14171


(cherry picked from commit 9f64c7f354)
This commit is contained in:
Marek Roszko 2023-04-20 23:17:39 -04:00 committed by Mark Roszko
parent b74af71312
commit 9956c04526
1 changed files with 12 additions and 0 deletions

View File

@ -37,6 +37,7 @@
#include <board_design_settings.h>
#include <pcb_marker.h>
#include <cstdlib>
#include <drawing_sheet/ds_data_model.h>
#include <drc/drc_engine.h>
#include <drc/drc_item.h>
#include <fp_lib_table.h>
@ -54,6 +55,7 @@
#include <wildcards_and_files_ext.h>
#include <locale_io.h>
#include <wx/app.h>
#include <wx/crt.h>
static PCB_EDIT_FRAME* s_PcbEditFrame = nullptr;
@ -156,6 +158,16 @@ BOARD* LoadBoard( wxString& aFileName, IO_MGR::PCB_FILE_T aFormat )
if( !project )
project = GetDefaultProject();
BASE_SCREEN::m_DrawingSheetFileName = project->GetProjectFile().m_BoardDrawingSheetFile;
// Load the drawing sheet from the filename stored in BASE_SCREEN::m_DrawingSheetFileName.
// If empty, or not existing, the default drawing sheet is loaded.
wxString filename = DS_DATA_MODEL::ResolvePath( BASE_SCREEN::m_DrawingSheetFileName,
project->GetProjectPath() );
if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( filename ) )
wxFprintf( stderr, _( "Error loading drawing sheet." ) );
BOARD* brd = IO_MGR::Load( aFormat, aFileName );
if( brd )