diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 33af868978..7466009654 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -576,6 +576,13 @@ void SCH_COMPONENT::SetUnitSelection( const SCH_SHEET_PATH* aSheet, int aUnitSel } +void SCH_COMPONENT::SetUnitSelection( int aUnitSelection ) +{ + for( SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences ) + instance.m_Unit = aUnitSelection; +} + + const wxString SCH_COMPONENT::GetValue( const SCH_SHEET_PATH* sheet, bool aResolve ) const { KIID_PATH path = sheet->Path(); diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index dafb56ff1d..1d68b0bbea 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -553,8 +553,13 @@ public: // Returns the instance-specific unit selection for the given sheet path. int GetUnitSelection( const SCH_SHEET_PATH* aSheet ) const; + + // Set the selected unit of this symbol on one sheet void SetUnitSelection( const SCH_SHEET_PATH* aSheet, int aUnitSelection ); + // Set the selected unit of this symbol for all sheets + void SetUnitSelection( int aUnitSelection ); + // Returns the instance-specific value for the given sheet path. const wxString GetValue( const SCH_SHEET_PATH* sheet, bool aResolve ) const; void SetValue( const SCH_SHEET_PATH* sheet, const wxString& aValue ); diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 3c110e1120..7ef7118727 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -252,7 +252,7 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent ) next_comp = static_cast( component->Duplicate() ); next_comp->SetFlags( IS_NEW | IS_MOVED ); next_comp->SetUnit( new_unit ); - next_comp->SetUnitSelection( &m_frame->GetCurrentSheet(), new_unit ); + next_comp->SetUnitSelection( new_unit ); if( m_frame->eeconfig()->m_AutoplaceFields.enable ) component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );