kicad2step: Set correct file extension if no output file is specified

This commit is contained in:
Maciej Suminski 2018-09-11 09:22:10 +02:00
parent 3ad1cd8d57
commit 7037e422a8
1 changed files with 22 additions and 10 deletions

View File

@ -43,6 +43,9 @@ public:
virtual bool OnCmdLineParsed(wxCmdLineParser& parser) override; virtual bool OnCmdLineParsed(wxCmdLineParser& parser) override;
private: private:
///> Returns file extension for the selected output format
wxString getOutputExt() const;
#ifdef SUPPORTS_IGES #ifdef SUPPORTS_IGES
bool m_fmtIGES; bool m_fmtIGES;
#endif #endif
@ -250,23 +253,21 @@ int KICAD2MCAD::OnRun()
wxFileName tfname; wxFileName tfname;
if( m_outputFile.empty() ) if( m_outputFile.empty() )
{
tfname.Assign( fname.GetFullPath() ); tfname.Assign( fname.GetFullPath() );
tfname.SetExt( getOutputExt() );
}
else else
{
tfname.Assign( m_outputFile ); tfname.Assign( m_outputFile );
// Set the file extension if the user's requested file name does not have an extension. // Set the file extension if the user's requested
if( !tfname.HasExt() ) // file name does not have an extension.
{ if( !tfname.HasExt() )
#ifdef SUPPORTS_IGES tfname.SetExt( getOutputExt() );
if( m_fmtIGES )
tfname.SetExt( "igs" );
else
#endif
tfname.SetExt( "stp" );
} }
wxString outfile = tfname.GetFullPath(); wxString outfile = tfname.GetFullPath();
KICADPCB pcb; KICADPCB pcb;
pcb.SetOrigin( m_xOrigin, m_yOrigin ); pcb.SetOrigin( m_xOrigin, m_yOrigin );
@ -310,3 +311,14 @@ int KICAD2MCAD::OnRun()
return 0; return 0;
} }
wxString KICAD2MCAD::getOutputExt() const
{
#ifdef SUPPORTS_IGES
if( m_fmtIGES )
return wxString( "igs" );
else
#endif
return wxString( "stp" );
}