diff --git a/demos/python_scripts_examples/action_menu_add_automatic_border.py b/demos/python_scripts_examples/action_menu_add_automatic_border.py index 994d8e4d48..e447db4fb2 100644 --- a/demos/python_scripts_examples/action_menu_add_automatic_border.py +++ b/demos/python_scripts_examples/action_menu_add_automatic_border.py @@ -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 ) ) diff --git a/demos/python_scripts_examples/gen_gerber_and_drill_files_board.py b/demos/python_scripts_examples/gen_gerber_and_drill_files_board.py index 5ab79b0eb2..e5cccd766f 100644 --- a/demos/python_scripts_examples/gen_gerber_and_drill_files_board.py +++ b/demos/python_scripts_examples/gen_gerber_and_drill_files_board.py @@ -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,11 +99,13 @@ 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: - print("plot error") + print( "plot error" ) #generate internal copper layers, if any lyrcnt = board.GetCopperLayerCount(); @@ -106,9 +115,11 @@ 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") + print( "plot error" ) # At the end you have to close the last plot, otherwise you don't know when @@ -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 ) diff --git a/demos/python_scripts_examples/plot_board.py b/demos/python_scripts_examples/plot_board.py index 9a9403bb76..732d11f215 100644 --- a/demos/python_scripts_examples/plot_board.py +++ b/demos/python_scripts_examples/plot_board.py @@ -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) @@ -72,7 +74,7 @@ plot_plan = [ for layer_info in plot_plan: pctl.SetLayer(layer_info[1]) pctl.OpenPlotfile(layer_info[0], PLOT_FORMAT_GERBER, layer_info[2]) - print(layer_info[0]) + print ( layer_info[0] ) pctl.PlotLayer() # Our fabricators want two additional gerbers: @@ -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()