From 9f64c7f3549f28503464eba1f2ba741efd8d7ef9 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Thu, 20 Apr 2023 23:17:39 -0400 Subject: [PATCH] Load custom drawing sheets for pcb cli Fixes https://gitlab.com/kicad/code/kicad/-/issues/14171 --- pcbnew/python/scripting/pcbnew_scripting_helpers.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp index 279981ebfc..b57d10cbe5 100644 --- a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp +++ b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -54,6 +55,7 @@ #include #include #include +#include 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 )