44 if( ( f = wxFopen( aOutFileName, wxT(
"wt" ) ) ) ==
nullptr )
46 wxString msg = wxString::Format(
_(
"Failed to create file '%s'." ), aOutFileName );
53 wxString StartCmpDesc =
StartLine + wxT(
"ADD_COM" );
62 fmt::print( f,
"\"{}\"\n",
TO_UTF8( title ) );
63 fmt::print( f,
".TYP FULL\n\n" );
73 std::vector<EDA_ITEM*> sheetItems;
76 sheetItems.push_back( item );
80 return item1->
m_Uuid < item2->m_Uuid;
83 std::sort( sheetItems.begin(), sheetItems.end(), pred );
98 if( footprint.IsEmpty() )
99 footprint =
"$noname";
101 msg = symbol->
GetRef( &sheet );
102 fmt::print( f,
"{} ",
TO_UTF8( StartCmpDesc ) );
103 fmt::print( f,
"{}",
TO_UTF8( msg ) );
105 msg = symbol->
GetValue(
true, &sheet,
false );
106 msg.Replace( wxT(
" " ), wxT(
"_" ) );
107 fmt::print( f,
" \"{}\"",
TO_UTF8( msg ) );
108 fmt::print( f,
" \"{}\"",
TO_UTF8( footprint ) );
109 fmt::print( f,
"\n" );
113 fmt::print( f,
"\n" );
124 catch(
const std::system_error& e )
129 catch(
const fmt::format_error& e )
147 wxString InitNetDesc =
StartLine + wxT(
"ADD_TER" );
148 wxString StartNetDesc =
StartLine + wxT(
"TER" );
149 wxString InitNetDescLine;
151 std::vector<std::pair<wxString, std::vector<std::pair<SCH_PIN*, SCH_SHEET_PATH>>>> all_nets;
153 for(
const auto& [ key, subgraphs ] :
m_schematic->ConnectionGraph()->GetNetMap() )
156 netName.Printf( wxT(
"\"%s\"" ), key.Name );
158 all_nets.emplace_back( netName, std::vector<std::pair<SCH_PIN*, SCH_SHEET_PATH>>{} );
159 std::vector<std::pair<SCH_PIN*, SCH_SHEET_PATH>>& sorted_items = all_nets.back().second;
165 for(
SCH_ITEM* item : subgraph->GetItems() )
168 sorted_items.emplace_back(
static_cast<SCH_PIN*
>( item ), sheet );
173 std::sort( sorted_items.begin(), sorted_items.end(),
174 [](
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& a,
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& b )
176 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
177 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
180 return a.first->GetShownNumber() < b.first->GetShownNumber();
182 return ref_a < ref_b;
188 sorted_items.erase( std::unique( sorted_items.begin(), sorted_items.end(),
189 [](
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& a,
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& b )
191 wxString ref_a = a.first->GetParentSymbol()->GetRef( &a.second );
192 wxString ref_b = b.first->GetParentSymbol()->GetRef( &b.second );
194 return ref_a == ref_b && a.first->GetShownNumber() == b.first->GetShownNumber();
196 sorted_items.end() );
200 std::sort( all_nets.begin(), all_nets.end(),
201 [](
const auto& a,
const auto& b )
203 return a.first < b.first;
206 for(
const auto& [netName, sorted_items] : all_nets )
210 for(
const std::pair<SCH_PIN*, SCH_SHEET_PATH>& pair : sorted_items )
215 wxString refText =
pin->GetParentSymbol()->GetRef( &sheet );
216 wxString pinText =
pin->GetShownNumber();
219 if( refText[0] == wxChar(
'#' ) )
225 InitNetDescLine.Printf( wxT(
"\n%s %s %s %s" ),
234 fmt::print( f,
"{}\n",
TO_UTF8( InitNetDescLine ) );
235 fmt::print( f,
"{} {} {}\n",
243 fmt::print( f,
" {} {}\n",
251 return ferror( f ) == 0;
253 catch(
const std::system_error& )
257 catch(
const fmt::format_error& )