From 2703bd6b81fc674025030f1dc43e4794a5019308 Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Wed, 15 Apr 2020 16:01:02 +0200 Subject: [PATCH] alitum: set layer name, fix handling of odd layercount --- pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp b/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp index 9e1f2bb3d1..d6af27dcae 100644 --- a/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp +++ b/pcbnew/altium2kicadpcb_plugin/altium_pcb.cpp @@ -500,7 +500,7 @@ void ALTIUM_PCB::ParseBoard6Data( for( size_t i = static_cast( ALTIUM_LAYER::TOP_LAYER ); i < elem.stackup.size() && i != 0; i = elem.stackup[i - 1].nextId, layercount++ ) ; - size_t kicadLayercount = layercount % 2 == 0 ? layercount : layercount + 1; + size_t kicadLayercount = ( layercount % 2 == 0 ) ? layercount : layercount + 1; m_board->SetCopperLayerCount( kicadLayercount ); BOARD_DESIGN_SETTINGS& designSettings = m_board->GetDesignSettings(); @@ -517,13 +517,15 @@ void ALTIUM_PCB::ParseBoard6Data( auto curLayer = static_cast( F_Cu ); for( size_t i = static_cast( ALTIUM_LAYER::TOP_LAYER ); - i < elem.stackup.size() && i != 0; i = elem.stackup[i - 1].nextId, layercount++ ) + i < elem.stackup.size() && i != 0; i = elem.stackup[i - 1].nextId ) { auto layer = elem.stackup.at( i - 1 ); // array starts with 0, but stackup with 1 - // handle unused layer - if( i == elem.stackup.size() - 1 && layercount != kicadLayercount ) + // handle unused layer in case of odd layercount + if( layer.nextId == 0 && layercount != kicadLayercount ) { + m_board->SetLayerName( ( *it )->GetBrdLayerId(), "[unused]" ); + if( ( *it )->GetType() != BS_ITEM_TYPE_COPPER ) { THROW_IO_ERROR( "Board6 stream, unexpected item while parsing stackup" ); @@ -536,6 +538,7 @@ void ALTIUM_PCB::ParseBoard6Data( THROW_IO_ERROR( "Board6 stream, unexpected item while parsing stackup" ); } ( *it )->SetThickness( 0, 0 ); + ( *it )->SetThicknessLocked( true, 0 ); ++it; } @@ -548,6 +551,8 @@ void ALTIUM_PCB::ParseBoard6Data( } ( *it )->SetThickness( layer.copperthick ); + m_board->SetLayerName( ( *it )->GetBrdLayerId(), layer.name ); + if( ( *it )->GetBrdLayerId() == B_Cu ) { if( layer.nextId != 0 )