diff --git a/pcbnew/tools/multichannel_tool.cpp b/pcbnew/tools/multichannel_tool.cpp index 212ba51d26..b211fdb40b 100644 --- a/pcbnew/tools/multichannel_tool.cpp +++ b/pcbnew/tools/multichannel_tool.cpp @@ -745,6 +745,11 @@ bool MULTICHANNEL_TOOL::copyRuleAreaContents( TMATCH::COMPONENT_MATCHES& aMatche BOARD_ITEM* copied = static_cast( item->Clone() ); + if( item->Type() == PCB_VIA_T ) + { + fixupNet( static_cast( item ), static_cast( copied ), + aMatches ); + } copied->Move( disp ); copied->SetParentGroup( nullptr ); aGroupableItems.insert( copied ); @@ -848,7 +853,7 @@ bool MULTICHANNEL_TOOL::copyRuleAreaContents( TMATCH::COMPONENT_MATCHES& aMatche continue; ZONE* targetZone = static_cast( item->Clone() ); - fixupZoneNets( zone, targetZone, aMatches ); + fixupNet( zone, targetZone, aMatches ); copied = targetZone; } @@ -924,19 +929,18 @@ bool MULTICHANNEL_TOOL::copyRuleAreaContents( TMATCH::COMPONENT_MATCHES& aMatche return true; } - /** - * @brief Attempts to modify the assigned net of a copied zone + * @brief Attempts to modify the assigned net of copied items, especially intended for zones and vias * */ -void MULTICHANNEL_TOOL::fixupZoneNets( ZONE* aRefZone, ZONE* aTargetZone, - TMATCH::COMPONENT_MATCHES& aComponentMatches ) +void MULTICHANNEL_TOOL::fixupNet( BOARD_CONNECTED_ITEM* aRef, BOARD_CONNECTED_ITEM* aTarget, + TMATCH::COMPONENT_MATCHES& aComponentMatches ) { auto connectivity = board()->GetConnectivity(); - const std::vector refZoneConnectedPads = - connectivity->GetNetItems( aRefZone->GetNetCode(), { PCB_PAD_T } ); + const std::vector refConnectedPads = + connectivity->GetNetItems( aRef->GetNetCode(), { PCB_PAD_T } ); - for( const BOARD_CONNECTED_ITEM* refConItem : refZoneConnectedPads ) + for( const BOARD_CONNECTED_ITEM* refConItem : refConnectedPads ) { if( refConItem->Type() != PCB_PAD_T ) continue; @@ -952,7 +956,7 @@ void MULTICHANNEL_TOOL::fixupZoneNets( ZONE* aRefZone, ZONE* aTargetZone, if( !targetFpPads.empty() ) { int targetNetCode = targetFpPads[0]->GetNet()->GetNetCode(); - aTargetZone->SetNetCode( targetNetCode ); + aTarget->SetNetCode( targetNetCode ); break; } diff --git a/pcbnew/tools/multichannel_tool.h b/pcbnew/tools/multichannel_tool.h index 243ead0646..2af037f930 100644 --- a/pcbnew/tools/multichannel_tool.h +++ b/pcbnew/tools/multichannel_tool.h @@ -145,8 +145,8 @@ private: std::shared_ptr aConnectivity, const SHAPE_POLY_SET& aRAPoly, RULE_AREA* aRA, FOOTPRINT* aFp, const REPEAT_LAYOUT_OPTIONS& aOpts ) const; - void fixupZoneNets( ZONE* aRefZone, ZONE* aTargetZone, - TMATCH::COMPONENT_MATCHES& aComponentMatches ); + void fixupNet( BOARD_CONNECTED_ITEM* aRef, BOARD_CONNECTED_ITEM* aTarget, + TMATCH::COMPONENT_MATCHES& aComponentMatches ); bool pruneExistingGroups( COMMIT& aCommit, const std::unordered_set& aItemsToCheck );