diff --git a/pcbnew/kicad_clipboard.cpp b/pcbnew/kicad_clipboard.cpp index 500a52e682..73981c006a 100644 --- a/pcbnew/kicad_clipboard.cpp +++ b/pcbnew/kicad_clipboard.cpp @@ -102,7 +102,13 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected, bool isModE for( const EDA_ITEM* item : aSelected ) { - BOARD_ITEM* clone = static_cast( item->Clone() ); + const PCB_GROUP* group = dynamic_cast( item ); + BOARD_ITEM* clone; + + if( group ) + clone = static_cast( group->DeepClone() ); + else + clone = static_cast( item->Clone() ); // Do not add reference/value - convert them to the common type if( FP_TEXT* text = dyn_cast( clone ) ) @@ -115,6 +121,15 @@ void CLIPBOARD_IO::SaveSelection( const PCBNEW_SELECTION& aSelected, bool isModE // Add the pad to the new module before moving to ensure the local coords are correct partialModule.Add( clone ); + if( group ) + { + static_cast( clone )->RunOnDescendants( + [&]( BOARD_ITEM* descendant ) + { + partialModule.Add( descendant ); + } ); + } + // locate the reference point at (0, 0) in the copied items clone->Move( (wxPoint) -refPoint ); }