diff --git a/eeschema/netlist_exporters/netlist_exporter_spice.cpp b/eeschema/netlist_exporters/netlist_exporter_spice.cpp index a0caa2159a..b4326f230a 100644 --- a/eeschema/netlist_exporters/netlist_exporter_spice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_spice.cpp @@ -70,6 +70,8 @@ bool NETLIST_EXPORTER_SPICE::WriteNetlist( const wxString& aOutFileName, unsigne bool NETLIST_EXPORTER_SPICE::GenerateNetlist( OUTPUTFORMATTER& aFormatter, unsigned aNetlistOptions ) { + LOCALE_IO dummy; + // Cleanup list to avoid duplicate if the netlist exporter is run more than once. m_rawIncludes.clear(); @@ -182,6 +184,31 @@ void NETLIST_EXPORTER_SPICE::ReadDirectives() else continue; + // Some directives have a plain text inside them: + // .control (that ends with .endc + // .subckt (that ends with .ends + // So we insert the full text in netlist without any test + // (it is not the right place here to verify the directive) + if( text.StartsWith( ".control" ) || text.StartsWith( ".subckt") ) + { + m_directives.emplace_back( text ); + continue; + } + + // A specific "directive" allows entering coupling parameter between 2 inductors + // Kxx Lyy Lzz nn (xx, yy, zz are digits, nn is the coupling value + if( text.StartsWith( "K" ) ) + { + wxRegEx couplingK( "^[kK][[:digit:]]*[[:space:]]+[[:alnum:]]+[[:space:]]+[[:alnum:]]+", + wxRE_ADVANCED ); + + if( couplingK.Matches( text ) ) // K## L## L## coupling constant + { + m_directives.emplace_back( text ); + continue; + } + } + tao::pegtl::string_input<> in( ( text + "\n" ).ToUTF8(), "from_content" ); std::unique_ptr root; @@ -201,7 +228,9 @@ void NETLIST_EXPORTER_SPICE::ReadDirectives() for( const auto& node : root->children ) { if( node->is_type() ) + { m_title = node->children.at( 0 )->string(); + } else if( node->is_type() ) { wxString path = node->children.at( 0 )->string(); @@ -358,8 +387,6 @@ void NETLIST_EXPORTER_SPICE::readPinNetNames( SCH_SYMBOL& aSymbol, SPICE_ITEM& a ReplaceForbiddenChars( netName ); netName = UnescapeString( netName ); - LOCALE_IO toggle; - if( netName == "" ) netName = wxString::Format( wxT( "NC-%u" ), aNCCounter++ );