43 if( ( f = wxFopen( aOutFileName, wxT(
"wt" ) ) ) ==
nullptr )
45 wxString msg = wxString::Format(
_(
"Failed to create file '%s'." ), aOutFileName );
56 fmt::print( f,
"*PADS-PCB*\n" );
57 fmt::print( f,
"*PART*\n" );
76 footprint = footprint.Trim(
true );
77 footprint = footprint.Trim(
false );
78 footprint.Replace( wxT(
" " ), wxT(
"_" ) );
80 if( footprint.IsEmpty() )
83 footprint = symbol->
GetValue(
true, &sheet,
false );
84 footprint.Replace( wxT(
" " ), wxT(
"_" ) );
85 footprint = footprint.Trim(
true );
86 footprint = footprint.Trim(
false );
89 msg = symbol->
GetRef( &sheet );
90 fmt::print( f,
"{:<16} {}\n",
TO_UTF8( msg ),
TO_UTF8( footprint ) );
94 fmt::print( f,
"\n" );
102 catch(
const std::system_error& e )
107 catch(
const fmt::format_error& e )
125 fmt::print( f,
"*NET*\n" );
128 std::vector<std::pair<wxString, std::vector<std::pair<SCH_PIN*, SCH_SHEET_PATH>>>> allNets;
130 for(
const auto& [ key, subgraphs ] :
m_schematic->ConnectionGraph()->GetNetMap() )
134 std::vector<std::pair<SCH_PIN*, SCH_SHEET_PATH>> sortedItems;
140 for(
SCH_ITEM* item : subgraph->GetItems() )
143 sortedItems.emplace_back(
static_cast<SCH_PIN*
>( item ), sheet );
148 std::sort( sortedItems.begin(), sortedItems.end(),
149 [](
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& a,
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& b )
151 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
152 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
155 return a.first->GetShownNumber() < b.first->GetShownNumber();
157 return ref_a < ref_b;
161 sortedItems.erase( std::unique( sortedItems.begin(), sortedItems.end(),
162 [](
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& a,
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& b )
164 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
165 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
167 return ref_a == ref_b && a.first->GetShownNumber() == b.first->GetShownNumber();
171 allNets.emplace_back( netName, std::move( sortedItems ) );
175 std::sort( allNets.begin(), allNets.end(),
176 [](
const auto& a,
const auto& b )
178 return a.first < b.first;
181 for(
const auto& [sortedNetName, sorted_items] : allNets )
183 std::vector<wxString> netConns;
185 for(
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& pair : sorted_items )
190 wxString refText =
pin->GetParentSymbol()->GetRef( &sheet );
191 wxString pinText =
pin->GetShownNumber();
194 if( refText[0] == wxChar(
'#' ) )
197 netConns.push_back( wxString::Format(
"%s.%.4s", refText, pinText ) );
202 if( netConns .size() > 1 )
204 fmt::print( f,
"*SIGNAL* {}\n",
TO_UTF8(sortedNetName) );
207 for( wxString& netConn : netConns )
209 fmt::print( f,
"{}",
TO_UTF8( netConn ) );
211 if( cnt != 0 && cnt % 6 == 0 )
212 fmt::print( f,
"\n" );
214 fmt::print( f,
" " );
219 fmt::print( f,
"\n" );
223 fmt::print( f,
"*END*\n" );
225 return ferror( f ) == 0;
227 catch(
const std::system_error& )
231 catch(
const fmt::format_error& )