39 if( ( f = wxFopen( aOutFileName, wxT(
"wt" ) ) ) ==
nullptr )
41 wxString msg = wxString::Format(
_(
"Failed to create file '%s'." ), aOutFileName );
52 fmt::print( f,
"*PADS-PCB*\n" );
53 fmt::print( f,
"*PART*\n" );
63 std::vector<EDA_ITEM*> sheetItems;
66 sheetItems.push_back( item );
70 return item1->
m_Uuid < item2->m_Uuid;
73 std::sort( sheetItems.begin(), sheetItems.end(), pred );
87 footprint = footprint.Trim(
true );
88 footprint = footprint.Trim(
false );
89 footprint.Replace( wxT(
" " ), wxT(
"_" ) );
91 if( footprint.IsEmpty() )
95 footprint.Replace( wxT(
" " ), wxT(
"_" ) );
96 footprint = footprint.Trim(
true );
97 footprint = footprint.Trim(
false );
100 msg = symbol->
GetRef( &sheet );
101 fmt::print( f,
"{:<16} {}\n",
TO_UTF8( msg ),
TO_UTF8( footprint ) );
105 fmt::print( f,
"\n" );
113 catch(
const std::system_error& e )
118 catch(
const fmt::format_error& e )
134 fmt::print( f,
"*NET*\n" );
137 std::vector<std::pair<wxString, std::vector<std::pair<SCH_PIN*, SCH_SHEET_PATH>>>> allNets;
140 allNets.emplace_back( net.name, net.pins );
142 for(
auto& [netName, sortedItems] : allNets )
145 std::sort( sortedItems.begin(), sortedItems.end(),
146 [](
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& a,
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& b )
148 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
149 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
152 return a.first->GetShownNumber() < b.first->GetShownNumber();
154 return ref_a < ref_b;
158 sortedItems.erase( std::unique( sortedItems.begin(), sortedItems.end(),
159 [](
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& a,
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& b )
161 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
162 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
164 return ref_a == ref_b && a.first->GetShownNumber() == b.first->GetShownNumber();
171 std::sort( allNets.begin(), allNets.end(),
172 [](
const auto& a,
const auto& b )
174 return a.first < b.first;
177 for(
const auto& [sortedNetName, sorted_items] : allNets )
179 std::vector<wxString> netConns;
181 for(
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& pair : sorted_items )
186 wxString refText =
pin->GetParentSymbol()->GetRef( &sheet );
187 wxString pinText =
pin->GetShownNumber();
190 if( refText[0] == wxChar(
'#' ) )
193 netConns.push_back( wxString::Format(
"%s.%s", refText, pinText ) );
198 if( netConns .size() > 1 )
200 fmt::print( f,
"*SIGNAL* {}\n",
TO_UTF8(sortedNetName) );
203 for( wxString& netConn : netConns )
205 fmt::print( f,
"{}",
TO_UTF8( netConn ) );
207 if( cnt != 0 && cnt % 6 == 0 )
208 fmt::print( f,
"\n" );
210 fmt::print( f,
" " );
215 fmt::print( f,
"\n" );
219 fmt::print( f,
"*END*\n" );
221 return ferror( f ) == 0;
223 catch(
const std::system_error& )
227 catch(
const fmt::format_error& )