diff --git a/pcbnew/api/api_handler_pcb.cpp b/pcbnew/api/api_handler_pcb.cpp index f52c5e9361..fe0155ef5c 100644 --- a/pcbnew/api/api_handler_pcb.cpp +++ b/pcbnew/api/api_handler_pcb.cpp @@ -494,22 +494,10 @@ HANDLER_RESULT<BoardStackupResponse> API_HANDLER_PCB::handleGetStackup( GetBoard if( !documentValidation ) return tl::unexpected( documentValidation.error() ); - const BOARD* board = frame()->GetBoard(); - BoardStackupResponse response; + BoardStackupResponse response; google::protobuf::Any any; - const BOARD_DESIGN_SETTINGS& bds = board->GetDesignSettings(); - if( frame()->GetBoard()->GetDesignSettings().m_HasStackup ) - { - const BOARD_STACKUP& stackup = bds.GetStackupDescriptor(); - stackup.Serialize( any ); - } - else - { - BOARD_STACKUP stackup; - stackup.BuildDefaultStackupList( &bds, board->GetCopperLayerCount() ); - stackup.Serialize( any ); - } + frame()->GetBoard()->GetStackupOrDefault().Serialize( any ); any.UnpackTo( response.mutable_stackup() ); diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 5fbdc97fd1..930a1e40d5 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -2174,6 +2174,17 @@ void BOARD::GetSortedPadListByXthenYCoord( std::vector<PAD*>& aVector, int aNetC } +BOARD_STACKUP BOARD::GetStackupOrDefault() const +{ + if( GetDesignSettings().m_HasStackup ) + return GetDesignSettings().GetStackupDescriptor(); + + BOARD_STACKUP stackup; + stackup.BuildDefaultStackupList( &GetDesignSettings(), GetCopperLayerCount() ); + return stackup; +} + + std::tuple<int, double, double> BOARD::GetTrackLength( const PCB_TRACK& aTrack ) const { int count = 0; diff --git a/pcbnew/board.h b/pcbnew/board.h index 8b388e5493..b02d9cb4d5 100644 --- a/pcbnew/board.h +++ b/pcbnew/board.h @@ -26,6 +26,7 @@ #define CLASS_BOARD_H_ #include <board_item_container.h> +#include <board_stackup_manager/board_stackup.h> #include <common.h> // Needed for stl hash extensions #include <convert_shape_list_to_polygon.h> // for OUTLINE_ERROR_HANDLER #include <hash.h> @@ -660,6 +661,8 @@ public: */ BOARD_DESIGN_SETTINGS& GetDesignSettings() const; + BOARD_STACKUP GetStackupOrDefault() const; + // Tented vias are vias covered by solder mask. So because the solder mask is a negative // layer, tented vias are NOT plotted on solder mask layers bool GetTentVias() const { return !m_plotOptions.GetPlotViaOnMaskLayer(); } diff --git a/pcbnew/exporters/step/exporter_step.cpp b/pcbnew/exporters/step/exporter_step.cpp index ed68bc64cf..065236f90c 100644 --- a/pcbnew/exporters/step/exporter_step.cpp +++ b/pcbnew/exporters/step/exporter_step.cpp @@ -448,9 +448,7 @@ bool EXPORTER_STEP::buildBoard3DShapes() m_pcbModel->SetBoardColor( m_solderMaskColor.r, m_solderMaskColor.g, m_solderMaskColor.b ); m_pcbModel->SetCopperColor( m_copperColor.r, m_copperColor.g, m_copperColor.b ); - wxCHECK( m_board->GetDesignSettings().m_HasStackup, false ); - - m_pcbModel->SetStackup( m_board->GetDesignSettings().GetStackupDescriptor() ); + m_pcbModel->SetStackup( m_board->GetStackupOrDefault() ); m_pcbModel->SetEnabledLayers( layersToExport ); m_pcbModel->SetFuseShapes( m_params.m_fuseShapes ); m_pcbModel->SetNetFilter( m_params.m_netFilter );