Update some python scripts to be compatible with python2/python3 and changes in Kicad code.
This commit is contained in:
parent
713f39ef71
commit
60719b66bb
|
@ -118,7 +118,7 @@ class add_automatic_border( ActionPlugin ):
|
|||
edge_candidate = False
|
||||
# Detect if current drawing is a PCB edge
|
||||
# and a candicate for north/south/east or west
|
||||
if draw.GetClass() == 'DRAWSEGMENT' \
|
||||
if draw.GetClass() == 'PCB_SHAPE' \
|
||||
and draw.GetLayer() == Edge_Cuts:
|
||||
# Try candicate for east/west ?
|
||||
if draw.GetStart().x == draw.GetEnd().x:
|
||||
|
@ -201,7 +201,7 @@ class add_automatic_border( ActionPlugin ):
|
|||
need_add = False
|
||||
if west is None:
|
||||
need_add = True
|
||||
west = DRAWSEGMENT()
|
||||
west = PCB_SHAPE()
|
||||
west.SetLayer( Edge_Cuts )
|
||||
|
||||
west.SetStart( wxPoint( min_x, min_y ) )
|
||||
|
@ -212,7 +212,7 @@ class add_automatic_border( ActionPlugin ):
|
|||
need_add = False
|
||||
if north is None:
|
||||
need_add = True
|
||||
north = DRAWSEGMENT()
|
||||
north = PCB_SHAPE()
|
||||
north.SetLayer( Edge_Cuts )
|
||||
|
||||
north.SetStart( wxPoint( min_x, min_y ) )
|
||||
|
@ -223,7 +223,7 @@ class add_automatic_border( ActionPlugin ):
|
|||
need_add = False
|
||||
if east is None:
|
||||
need_add = True
|
||||
east = DRAWSEGMENT()
|
||||
east = PCB_SHAPE()
|
||||
east.SetLayer( Edge_Cuts )
|
||||
|
||||
east.SetStart( wxPoint( max_x, min_y ) )
|
||||
|
@ -234,7 +234,7 @@ class add_automatic_border( ActionPlugin ):
|
|||
need_add = False
|
||||
if south is None:
|
||||
need_add = True
|
||||
south = DRAWSEGMENT()
|
||||
south = PCB_SHAPE()
|
||||
south.SetLayer( Edge_Cuts )
|
||||
|
||||
south.SetStart( wxPoint( min_x, max_y ) )
|
||||
|
|
|
@ -22,8 +22,15 @@
|
|||
|
||||
import sys
|
||||
import os
|
||||
|
||||
from pcbnew import *
|
||||
|
||||
# A helper function to convert a string filename for python2 or python3
|
||||
def getFName( afilename ):
|
||||
if sys.version_info < (3, 0):
|
||||
return afilename.encode()
|
||||
else:
|
||||
return afilename
|
||||
|
||||
filename=sys.argv[1]
|
||||
|
||||
board = LoadBoard(filename)
|
||||
|
@ -51,7 +58,6 @@ popt.SetIncludeGerberNetlistInfo(True)
|
|||
popt.SetCreateGerberJobFile(gen_job_file)
|
||||
popt.SetUseGerberProtelExtensions(False)
|
||||
popt.SetExcludeEdgeLayer(False);
|
||||
popt.SetScale(1)
|
||||
popt.SetUseAuxOrigin(True)
|
||||
|
||||
# This by gerbers only
|
||||
|
@ -73,6 +79,7 @@ jobfile_writer = GERBER_JOBFILE_WRITER( board )
|
|||
# param 2 is a comment
|
||||
plot_plan = [
|
||||
( "CuTop", F_Cu, "Top layer" ),
|
||||
( "In1Top", In1_Cu, "In1 layer" ),
|
||||
( "CuBottom", B_Cu, "Bottom layer" ),
|
||||
( "PasteBottom", B_Paste, "Paste Bottom" ),
|
||||
( "PasteTop", F_Paste, "Paste top" ),
|
||||
|
@ -92,7 +99,9 @@ for layer_info in plot_plan:
|
|||
|
||||
pctl.SetLayer(layer_info[1])
|
||||
pctl.OpenPlotfile(layer_info[0], PLOT_FORMAT_GERBER, layer_info[2])
|
||||
print('plot %s' % pctl.GetPlotFileName())
|
||||
|
||||
print( 'plot %s' % getFName( pctl.GetPlotFileName() ) )
|
||||
|
||||
if gen_job_file == True:
|
||||
jobfile_writer.AddGbrFile( layer_info[1], os.path.basename(pctl.GetPlotFileName()) );
|
||||
if pctl.PlotLayer() == False:
|
||||
|
@ -106,7 +115,9 @@ for innerlyr in range ( 1, lyrcnt-1 ):
|
|||
pctl.SetLayer(innerlyr)
|
||||
lyrname = 'inner%s' % innerlyr
|
||||
pctl.OpenPlotfile(lyrname, PLOT_FORMAT_GERBER, "inner")
|
||||
print('plot %s' % pctl.GetPlotFileName())
|
||||
|
||||
print( "plot %s" % getFName( pctl.GetPlotFileName() ) )
|
||||
|
||||
if pctl.PlotLayer() == False:
|
||||
print( "plot error" )
|
||||
|
||||
|
@ -133,18 +144,20 @@ drlwriter.SetFormat( metricFmt )
|
|||
|
||||
genDrl = True
|
||||
genMap = True
|
||||
print('create drill and map files in %s' % pctl.GetPlotDirName())
|
||||
print( 'create drill and map files in %s' % getFName( pctl.GetPlotFileName() ) )
|
||||
drlwriter.CreateDrillandMapFilesSet( pctl.GetPlotDirName(), genDrl, genMap );
|
||||
|
||||
# One can create a text file to report drill statistics
|
||||
rptfn = pctl.GetPlotDirName() + 'drill_report.rpt'
|
||||
print('report: %s' % rptfn)
|
||||
print( 'report: %s' % getFName( rptfn ) )
|
||||
drlwriter.GenDrillReportFile( rptfn );
|
||||
|
||||
if gen_job_file == True:
|
||||
#job_fn=os.path.splitext(pctl.GetPlotFileName())[0] + '.gbrjob'
|
||||
job_fn=os.path.dirname(pctl.GetPlotFileName()) + '/' + os.path.basename(filename)
|
||||
job_fn=os.path.splitext(job_fn)[0] + '.gbrjob'
|
||||
print('create job file %s' % job_fn)
|
||||
|
||||
print( 'create job file %s ' % getFName( job_fn ) )
|
||||
|
||||
jobfile_writer.CreateJobFile( job_fn )
|
||||
|
||||
|
|
|
@ -32,8 +32,10 @@ popt = pctl.GetPlotOptions()
|
|||
popt.SetOutputDirectory("plot/")
|
||||
|
||||
# Set some important plot options:
|
||||
# One cannot plot the frame references, because the board does not know
|
||||
# the frame references.
|
||||
popt.SetPlotFrameRef(False)
|
||||
popt.SetLineWidth(FromMM(0.35))
|
||||
popt.SetSketchPadLineWidth(FromMM(0.1))
|
||||
|
||||
popt.SetAutoScale(False)
|
||||
popt.SetScale(1)
|
||||
|
@ -106,9 +108,6 @@ popt.SetPlotReference(True)
|
|||
popt.SetPlotValue(True)
|
||||
popt.SetPlotInvisibleText(False)
|
||||
|
||||
# Comments in, uhmm... green
|
||||
#Note: currently, color is overidden by plot functions, so SetColor is not useful.
|
||||
popt.SetColor( COLOR4D( 1.0, 0, 0, 1.0 ) ) # color = RED, GREEN, BLUE, OPACITY )
|
||||
pctl.SetLayer(Cmts_User)
|
||||
pctl.PlotLayer()
|
||||
|
||||
|
|
Loading…
Reference in New Issue