diff --git a/eeschema/netform.cpp b/eeschema/netform.cpp
index 264e388a06..cc825a18c7 100644
--- a/eeschema/netform.cpp
+++ b/eeschema/netform.cpp
@@ -230,7 +230,6 @@ class EXPORT_HELP
*/
XNODE* makeGenericLibraries();
-
public:
/**
@@ -293,9 +292,56 @@ public:
*/
bool WriteNetListPspice( WinEDA_SchematicFrame* frame, FILE* f,
bool use_netnames );
+
+ /**
+ * Function MakeCommandLine
+ * builds up a string that describes a command line for
+ * executing a child process. The input and output file names
+ * along with any options to the executable are all possibly
+ * in the returned string.
+ *
+ * @param aFormatString holds:
+ *
+ * - the name of the external program
+ *
- any options needed by that program
+ *
- formatting sequences, see below.
+ *
+ *
+ * @param aTempfile is the name of an input file to the
+ * external program.
+ * @param aFinalFile is the name of an output file that
+ * the user expects.
+ *
+ * Supported formatting sequences and their meaning:
+ *
+ * - %B => base filename of selected output file, minus
+ * path and extension.
+ *
- %I => complete filename and path of the temporary
+ * input file.
+ *
- %O => complete filename and path of the user chosen
+ * output file.
+ *
+ */
+ static wxString MakeCommandLine( const wxString& aFormatString,
+ const wxString& aTempfile, const wxString& aFinalFile );
};
+wxString EXPORT_HELP::MakeCommandLine( const wxString& aFormatString,
+ const wxString& aTempfile, const wxString& aFinalFile )
+{
+ wxString ret = aFormatString;
+ wxFileName in = aTempfile;
+ wxFileName out = aFinalFile;
+
+ ret.Replace( wxT("%B"), out.GetName().GetData(), true );
+ ret.Replace( wxT("%I"), in.GetFullName().GetData(), true );
+ ret.Replace( wxT("%O"), out.GetFullName().GetData(), true );
+
+ return ret;
+}
+
+
/**
* Function WriteNetListFile
* creates the netlist file. Netlist info must be existing
@@ -356,22 +402,18 @@ bool WinEDA_SchematicFrame::WriteNetListFile( int aFormat, const wxString& aFull
if( !ret )
break;
- // Call the external module (plug in )
+ // If user provided no plugin command line, return now.
if( g_NetListerCommandLine.IsEmpty() )
break;
- wxString commandLine;
-
- if( wxIsAbsolutePath( g_NetListerCommandLine ) )
- commandLine = g_NetListerCommandLine;
- else
- commandLine = FindKicadFile( g_NetListerCommandLine );
-
- // this is the input file to the plugin
- commandLine += wxT( " " ) + tmpFile.GetFullPath();
-
- // this is the output file to the plugin
- commandLine += wxT( " " ) + aFullFileName;
+ // build full command line from user's format string, e.g.:
+ // "xsltproc -o %O /usr/local/lib/kicad/plugins/netlist_form_pads-pcb.xsl %I"
+ // becomes, after the user selects /tmp/s1.net as the output file from the file dialog:
+ // "xsltproc -o /tmp/s1.net /usr/local/lib/kicad/plugins/netlist_form_pads-pcb.xsl /tmp/s1.tmp"
+ wxString commandLine = EXPORT_HELP::MakeCommandLine(
+ g_NetListerCommandLine,
+ tmpFile.GetFullPath(),
+ aFullFileName );
ProcessExecute( commandLine, wxEXEC_SYNC );
@@ -1614,7 +1656,7 @@ bool EXPORT_HELP::writeGENERICListOfNets( FILE* f, NETLIST_OBJECT_LIST& aObjects
/* Generate CADSTAR net list. */
-wxString StartLine( wxT( "." ) );
+static wxString StartLine( wxT( "." ) );
void EXPORT_HELP::WriteNetListCADSTAR( WinEDA_SchematicFrame* frame, FILE* f )
diff --git a/eeschema/netlist_control.cpp b/eeschema/netlist_control.cpp
index c20d7aa7b8..5af4e9a4f0 100644
--- a/eeschema/netlist_control.cpp
+++ b/eeschema/netlist_control.cpp
@@ -445,6 +445,7 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event )
wxFileName fn;
wxString FileWildcard, FileExt;
wxString msg, Command;
+ wxString title = _( "Save Netlist File" );
NetlistUpdateOpt();
@@ -466,15 +467,20 @@ void WinEDA_NetlistFrame::GenNetlist( wxCommandEvent& event )
FileWildcard = _( "CadStar netlist file (.frp)|*.frp" );
break;
- default:
+ case NET_TYPE_PCBNEW:
FileExt = NetlistFileExtension;
FileWildcard = NetlistFileWildcard;
break;
+
+ default: // custom
+ FileExt = wxT( "*" );
+ FileWildcard = AllFilesWildcard;
+ title = _( "Generic Export" );
}
fn.SetExt( FileExt );
- wxFileDialog dlg( this, _( "Save Netlist Files" ), fn.GetPath(),
+ wxFileDialog dlg( this, title, fn.GetPath(),
fn.GetFullName(), FileWildcard,
wxFD_SAVE );