diff --git a/eeschema/sch_io/altium/sch_io_altium.cpp b/eeschema/sch_io/altium/sch_io_altium.cpp index e4c317a6d8..29991a4243 100644 --- a/eeschema/sch_io/altium/sch_io_altium.cpp +++ b/eeschema/sch_io/altium/sch_io_altium.cpp @@ -33,6 +33,8 @@ #include #include +#include +#include #include #include @@ -391,6 +393,36 @@ SCH_SHEET* SCH_IO_ALTIUM::LoadSchematicFile( const wxString& aFileName, SCHEMATI allSheets.UpdateSymbolLinks(); // Update all symbol library links for all sheets. allSheets.ClearEditFlags(); + // Set up the default netclass wire & bus width based on imported wires & buses. + // + + int minWireWidth = std::numeric_limits::max(); + int minBusWidth = std::numeric_limits::max(); + + for( SCH_SCREEN* screen = allSheets.GetFirst(); screen != nullptr; screen = allSheets.GetNext() ) + { + std::vector markers; + + for( SCH_ITEM* item : screen->Items().OfType( SCH_LINE_T ) ) + { + SCH_LINE* line = static_cast( item ); + + if( line->IsWire() && line->GetLineWidth() > 0 ) + minWireWidth = std::min( minWireWidth, line->GetLineWidth() ); + + if( line->IsBus() && line->GetLineWidth() > 0 ) + minBusWidth = std::min( minBusWidth, line->GetLineWidth() ); + } + } + + std::shared_ptr& netSettings = m_schematic->Prj().GetProjectFile().NetSettings(); + + if( minWireWidth < std::numeric_limits::max() ) + netSettings->m_DefaultNetClass->SetWireWidth( minWireWidth ); + + if( minBusWidth < std::numeric_limits::max() ) + netSettings->m_DefaultNetClass->SetBusWidth( minBusWidth ); + return m_rootSheet; }