plotcontroller: add method to get the current plot full file name and the current plot folder full path from Python script.
gen_gerber_and_drill_files_board.py: * fix to make it compatible with rev 6280. * allow this script to create files in the current plot folder defined from the board forder, no more only in current working directory.
This commit is contained in:
parent
c877c5ff6e
commit
bb95fcccfc
|
@ -72,7 +72,9 @@ plot_plan = [
|
||||||
for layer_info in plot_plan:
|
for layer_info in plot_plan:
|
||||||
pctl.SetLayer(layer_info[1])
|
pctl.SetLayer(layer_info[1])
|
||||||
pctl.OpenPlotfile(layer_info[0], PLOT_FORMAT_GERBER, layer_info[2])
|
pctl.OpenPlotfile(layer_info[0], PLOT_FORMAT_GERBER, layer_info[2])
|
||||||
pctl.PlotLayer()
|
print 'plot %s' % pctl.GetPlotFileName()
|
||||||
|
if pctl.PlotLayer() == False:
|
||||||
|
print "plot error"
|
||||||
|
|
||||||
#generate internal copper layers, if any
|
#generate internal copper layers, if any
|
||||||
lyrcnt = board.GetCopperLayerCount();
|
lyrcnt = board.GetCopperLayerCount();
|
||||||
|
@ -81,7 +83,9 @@ for innerlyr in range ( 1, lyrcnt-1 ):
|
||||||
pctl.SetLayer(innerlyr)
|
pctl.SetLayer(innerlyr)
|
||||||
lyrname = 'inner%s' % innerlyr
|
lyrname = 'inner%s' % innerlyr
|
||||||
pctl.OpenPlotfile(lyrname, PLOT_FORMAT_GERBER, "inner")
|
pctl.OpenPlotfile(lyrname, PLOT_FORMAT_GERBER, "inner")
|
||||||
pctl.PlotLayer()
|
print 'plot %s' % pctl.GetPlotFileName()
|
||||||
|
if pctl.PlotLayer() == False:
|
||||||
|
print "plot error"
|
||||||
|
|
||||||
|
|
||||||
# At the end you have to close the last plot, otherwise you don't know when
|
# At the end you have to close the last plot, otherwise you don't know when
|
||||||
|
@ -96,8 +100,7 @@ drlwriter.SetMapFileFormat( PLOT_FORMAT_PDF )
|
||||||
mirror = False
|
mirror = False
|
||||||
minimalHeader = False
|
minimalHeader = False
|
||||||
offset = wxPoint(0,0)
|
offset = wxPoint(0,0)
|
||||||
mergeNPTH = False
|
drlwriter.SetOptions( mirror, minimalHeader, offset )
|
||||||
drlwriter.SetOptions( mirror, minimalHeader, offset, mergeNPTH )
|
|
||||||
|
|
||||||
metricFmt = True
|
metricFmt = True
|
||||||
drlwriter.SetFormat( metricFmt )
|
drlwriter.SetFormat( metricFmt )
|
||||||
|
@ -107,5 +110,5 @@ genMap = True
|
||||||
drlwriter.CreateDrillandMapFilesSet( plotDir, genDrl, genMap );
|
drlwriter.CreateDrillandMapFilesSet( plotDir, genDrl, genMap );
|
||||||
|
|
||||||
# One can create a text file to report drill statistics
|
# One can create a text file to report drill statistics
|
||||||
rptfn = plotDir + '/drill_report.txt'
|
rptfn = pctl.GetPlotDirName() + 'drill_report.txt'
|
||||||
drlwriter.GenDrillReportFile( rptfn );
|
drlwriter.GenDrillReportFile( rptfn );
|
||||||
|
|
|
@ -371,7 +371,9 @@ bool PLOT_CONTROLLER::OpenPlotfile( const wxString &aSuffix,
|
||||||
|
|
||||||
if( EnsureFileDirectoryExists( &outputDir, boardFilename ) )
|
if( EnsureFileDirectoryExists( &outputDir, boardFilename ) )
|
||||||
{
|
{
|
||||||
wxFileName fn( boardFilename );
|
// outputDir contains now the full path of plot files
|
||||||
|
m_plotFile = boardFilename;
|
||||||
|
m_plotFile.SetPath( outputDir.GetPath() );
|
||||||
wxString fileExt = GetDefaultPlotExtension( aFormat );
|
wxString fileExt = GetDefaultPlotExtension( aFormat );
|
||||||
|
|
||||||
// Gerber format can use specific file ext, depending on layers
|
// Gerber format can use specific file ext, depending on layers
|
||||||
|
@ -380,10 +382,11 @@ bool PLOT_CONTROLLER::OpenPlotfile( const wxString &aSuffix,
|
||||||
GetPlotOptions().GetUseGerberProtelExtensions() )
|
GetPlotOptions().GetUseGerberProtelExtensions() )
|
||||||
fileExt = GetGerberProtelExtension( GetLayer() );
|
fileExt = GetGerberProtelExtension( GetLayer() );
|
||||||
|
|
||||||
BuildPlotFileName( &fn, outputDirName, aSuffix, fileExt );
|
// Build plot filenames from the board name and layer names:
|
||||||
|
BuildPlotFileName( &m_plotFile, outputDir.GetPath(), aSuffix, fileExt );
|
||||||
|
|
||||||
m_plotter = StartPlotBoard( m_board, &GetPlotOptions(), ToLAYER_ID( GetLayer() ),
|
m_plotter = StartPlotBoard( m_board, &GetPlotOptions(), ToLAYER_ID( GetLayer() ),
|
||||||
fn.GetFullPath(), aSheetDesc );
|
m_plotFile.GetFullPath(), aSheetDesc );
|
||||||
}
|
}
|
||||||
|
|
||||||
return( m_plotter != NULL );
|
return( m_plotter != NULL );
|
||||||
|
|
|
@ -40,6 +40,7 @@ class BOARD;
|
||||||
/**
|
/**
|
||||||
* Batch plotter state object. Keeps the plot options and handles multiple
|
* Batch plotter state object. Keeps the plot options and handles multiple
|
||||||
* plot requests
|
* plot requests
|
||||||
|
* Especially useful in Python scripts
|
||||||
*/
|
*/
|
||||||
class PLOT_CONTROLLER
|
class PLOT_CONTROLLER
|
||||||
{
|
{
|
||||||
|
@ -83,7 +84,27 @@ public:
|
||||||
*/
|
*/
|
||||||
bool PlotLayer();
|
bool PlotLayer();
|
||||||
|
|
||||||
void SetColorMode( bool aColorMode );
|
/**
|
||||||
|
* @return the current plot full filename, set by OpenPlotfile
|
||||||
|
*/
|
||||||
|
const wxString GetPlotFileName() { return m_plotFile.GetFullPath(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the current plot full filename, set by OpenPlotfile
|
||||||
|
*/
|
||||||
|
const wxString GetPlotDirName() { return m_plotFile.GetPathWithSep(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plotters can plot in Black and White mode or Color mode
|
||||||
|
* SetColorMode activate/de-actiavte the Color mode.
|
||||||
|
* @param aColorMode = true to activate the plot color mode
|
||||||
|
*/
|
||||||
|
void SetColorMode( bool );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the current plot color mode is Color,
|
||||||
|
* false if the current plot color mode is Black and White
|
||||||
|
*/
|
||||||
bool GetColorMode();
|
bool GetColorMode();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -99,6 +120,9 @@ private:
|
||||||
|
|
||||||
/// The board we're plotting
|
/// The board we're plotting
|
||||||
BOARD* m_board;
|
BOARD* m_board;
|
||||||
|
|
||||||
|
/// The current plot filename, set by OpenPlotfile
|
||||||
|
wxFileName m_plotFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue