Pcbnew export/import scripting functions.
Discussion can be found at https://forum.kicad.info/t/pcbnew-export-import-scripting-functions/16343 Fixes lp:1824668 https://bugs.launchpad.net/kicad/+bug/1824668
This commit is contained in:
parent
f87754848e
commit
3e4913adce
|
@ -1102,6 +1102,15 @@ public:
|
||||||
*/
|
*/
|
||||||
void ImportSpecctraSession( wxCommandEvent& event );
|
void ImportSpecctraSession( wxCommandEvent& event );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function ImportSpecctraSession
|
||||||
|
* will import a specctra *.ses file and use it to relocate MODULEs and
|
||||||
|
* to replace all vias and tracks in an existing and loaded BOARD.
|
||||||
|
* See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the
|
||||||
|
* specification.
|
||||||
|
*/
|
||||||
|
bool ImportSpecctraSession( const wxString& aFullFilename );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ImportSpecctraDesign
|
* Function ImportSpecctraDesign
|
||||||
* will import a specctra *.dsn file and use it to replace an entire BOARD.
|
* will import a specctra *.dsn file and use it to replace an entire BOARD.
|
||||||
|
|
|
@ -89,6 +89,13 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImportSpecctraSession( fullFileName );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PCB_EDIT_FRAME::ImportSpecctraSession( const wxString& fullFileName )
|
||||||
|
{
|
||||||
|
|
||||||
SetCurItem( NULL );
|
SetCurItem( NULL );
|
||||||
|
|
||||||
// To avoid issues with undo/redo lists (dangling pointers)
|
// To avoid issues with undo/redo lists (dangling pointers)
|
||||||
|
@ -114,7 +121,7 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
|
||||||
wxString extra = ioe.What();
|
wxString extra = ioe.What();
|
||||||
|
|
||||||
DisplayErrorMessage( this, msg, extra);
|
DisplayErrorMessage( this, msg, extra);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
OnModify();
|
OnModify();
|
||||||
|
@ -140,6 +147,8 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
|
||||||
SetStatusText( wxString( _( "Session file imported and merged OK." ) ) );
|
SetStatusText( wxString( _( "Session file imported and merged OK." ) ) );
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,47 @@ bool SaveBoard( wxString& aFileName, BOARD* aBoard )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ExportSpecctraDSN( wxString& aFullFilename )
|
||||||
|
{
|
||||||
|
if( s_PcbEditFrame )
|
||||||
|
{
|
||||||
|
bool ok = s_PcbEditFrame->ExportSpecctraFile( aFullFilename );
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ImportSpecctraSES( wxString& aFullFilename )
|
||||||
|
{
|
||||||
|
if( s_PcbEditFrame )
|
||||||
|
{
|
||||||
|
bool ok = s_PcbEditFrame->ImportSpecctraSession( aFullFilename );
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ArchiveModulesOnBoard( bool aStoreInNewLib, const wxString& aLibName, wxString* aLibPath )
|
||||||
|
{
|
||||||
|
if( s_PcbEditFrame )
|
||||||
|
{
|
||||||
|
s_PcbEditFrame->ArchiveModulesOnBoard( aStoreInNewLib, aLibName, aLibPath );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Refresh()
|
void Refresh()
|
||||||
{
|
{
|
||||||
if( s_PcbEditFrame )
|
if( s_PcbEditFrame )
|
||||||
|
|
|
@ -49,6 +49,39 @@ BOARD* LoadBoard( wxString& aFileName );
|
||||||
// so no option to choose the file format.
|
// so no option to choose the file format.
|
||||||
bool SaveBoard( wxString& aFileName, BOARD* aBoard );
|
bool SaveBoard( wxString& aFileName, BOARD* aBoard );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* will export the current BOARD to a specctra dsn file.
|
||||||
|
* See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the
|
||||||
|
* specification.
|
||||||
|
* @return true if OK
|
||||||
|
*/
|
||||||
|
bool ExportSpecctraDSN( wxString& aFullFilename );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* will import a specctra *.ses file and use it to relocate MODULEs and
|
||||||
|
* to replace all vias and tracks in an existing and loaded BOARD.
|
||||||
|
* See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the
|
||||||
|
* specification.
|
||||||
|
* @return true if OK
|
||||||
|
*/
|
||||||
|
bool ImportSpecctraSES( wxString& aFullFilename );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function ArchiveModulesOnBoard
|
||||||
|
* Save modules in a library:
|
||||||
|
* @param aStoreInNewLib:
|
||||||
|
* true : save modules in a existing lib. Existing footprints will be kept
|
||||||
|
* or updated.
|
||||||
|
* This lib should be in fp lib table, and is type is .pretty
|
||||||
|
* false: save modules in a new lib. It it is an existing lib,
|
||||||
|
* previous footprints will be removed
|
||||||
|
*
|
||||||
|
* @param aLibName:
|
||||||
|
* optional library name to create, stops dialog call.
|
||||||
|
* must be called with aStoreInNewLib as true
|
||||||
|
*/
|
||||||
|
bool ArchiveModulesOnBoard(
|
||||||
|
bool aStoreInNewLib, const wxString& aLibName = wxEmptyString, wxString* aLibPath = NULL );
|
||||||
/**
|
/**
|
||||||
* Update the board display after modifying it by a python script
|
* Update the board display after modifying it by a python script
|
||||||
* (note: it is automatically called by action plugins, after running the plugin,
|
* (note: it is automatically called by action plugins, after running the plugin,
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#
|
||||||
|
# manual test session for "Tools -> Scripting Console"
|
||||||
|
# verify that "board-archive.pretty" folder is present
|
||||||
|
# result should be identical to "File -> Archive -> ..."
|
||||||
|
#
|
||||||
|
import os
|
||||||
|
import pcbnew
|
||||||
|
board = pcbnew.GetBoard()
|
||||||
|
board_path = board.GetFileName()
|
||||||
|
path_tuple = os.path.splitext(board_path)
|
||||||
|
board_prefix = path_tuple[0]
|
||||||
|
aStoreInNewLib = True
|
||||||
|
aLibName = "footprint-export"
|
||||||
|
aLibPath = board_prefix + "-archive.pretty"
|
||||||
|
pcbnew.ArchiveModulesOnBoard(aStoreInNewLib,aLibName,aLibPath)
|
|
@ -0,0 +1,13 @@
|
||||||
|
#
|
||||||
|
# manual test session for "Tools -> Scripting Console"
|
||||||
|
# verify that "board.dsn" file is created after this session
|
||||||
|
# result should be identical to "File -> Export -> Specctra DSN"
|
||||||
|
#
|
||||||
|
import os
|
||||||
|
import pcbnew
|
||||||
|
board = pcbnew.GetBoard()
|
||||||
|
board_path = board.GetFileName()
|
||||||
|
path_tuple = os.path.splitext(board_path)
|
||||||
|
board_prefix = path_tuple[0]
|
||||||
|
export_path = board_prefix + ".dsn"
|
||||||
|
pcbnew.ExportSpecctraDSN(export_path)
|
|
@ -0,0 +1,13 @@
|
||||||
|
#
|
||||||
|
# manual test session for "Tools -> Scripting Console"
|
||||||
|
# verify that "board.ses" file is applied after this session
|
||||||
|
# result should be identical to "File -> Import -> Specctra Session"
|
||||||
|
#
|
||||||
|
import os
|
||||||
|
import pcbnew
|
||||||
|
board = pcbnew.GetBoard()
|
||||||
|
board_path = board.GetFileName()
|
||||||
|
path_tuple = os.path.splitext(board_path)
|
||||||
|
board_prefix = path_tuple[0]
|
||||||
|
import_path = board_prefix + ".ses"
|
||||||
|
pcbnew.ImportSpecctraSES(import_path)
|
Loading…
Reference in New Issue