From e2854ef524d2cf8da38016450944b152691e2238 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Sun, 12 Jul 2020 12:28:00 -0300 Subject: [PATCH] Added gerber.gerber_job_file option to control the gerber job file name. --- CHANGELOG.md | 1 + README.md | 1 + docs/samples/generic_plot.kiplot.yaml | 2 ++ kiplot/out_any_layer.py | 9 ++------- kiplot/out_gerber.py | 3 +++ tests/test_plot/test_gerber.py | 2 +- tests/yaml_samples/gerber_inner.kiplot.yaml | 1 + 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9127f9e9..84b200c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - filter_msg -> filter - error_number -> number - regexp -> regex +- gerber.gerber_job_file option to control the gerber job file name. ## [0.5.0] - 2020-07-11 ### Changed diff --git a/README.md b/README.md index efdf6115..cad2c20b 100644 --- a/README.md +++ b/README.md @@ -381,6 +381,7 @@ Next time you need this list just use an alias, like this: - `exclude_edge_layer`: [boolean=true] do not include the PCB edge layer. - `exclude_pads_from_silkscreen`: [boolean=false] do not plot the component pads in the silk screen. - `force_plot_invisible_refs_vals`: [boolean=false] include references and values even when they are marked as invisible. + - `gerber_job_file`: [string='%f-job.%x'] name for the gerber job file. - `gerber_precision`: [number=4.6] this the gerber coordinate format, can be 4.5 or 4.6. - `line_width`: [number=0.1] [0.02,2] line_width for objects without width [mm]. - `plot_footprint_refs`: [boolean=true] include the footprint references. diff --git a/docs/samples/generic_plot.kiplot.yaml b/docs/samples/generic_plot.kiplot.yaml index 3362d480..927fd7e4 100644 --- a/docs/samples/generic_plot.kiplot.yaml +++ b/docs/samples/generic_plot.kiplot.yaml @@ -116,6 +116,8 @@ outputs: exclude_pads_from_silkscreen: false # [boolean=false] include references and values even when they are marked as invisible force_plot_invisible_refs_vals: false + # [string='%f-job.%x'] name for the gerber job file + gerber_job_file: '%f-job.%x' # [number=4.6] this the gerber coordinate format, can be 4.5 or 4.6 gerber_precision: 4.6 # [number=0.1] [0.02,2] line_width for objects without width [mm] diff --git a/kiplot/out_any_layer.py b/kiplot/out_any_layer.py index 0d342853..3956cfe7 100644 --- a/kiplot/out_any_layer.py +++ b/kiplot/out_any_layer.py @@ -2,7 +2,6 @@ import os from pcbnew import (GERBER_JOBFILE_WRITER, PLOT_CONTROLLER, IsCopperLayer) from .out_base import (BaseOutput) from .error import (PlotError, KiPlotConfigurationError) -from .gs import (GS) from .optionable import BaseOptions from .layer import Layer from kiplot.macros import macros, document # noqa: F401 @@ -87,12 +86,8 @@ class AnyLayerOptions(BaseOptions): jobfile_writer.AddGbrFile(id, os.path.basename(plot_ctrl.GetPlotFileName())) if create_job: - base_fn = os.path.join( - os.path.dirname(plot_ctrl.GetPlotFileName()), - os.path.basename(GS.pcb_file)) - base_fn = os.path.splitext(base_fn)[0] - job_fn = base_fn+'-job.gbrjob' - jobfile_writer.CreateJobFile(job_fn) + job_fn = self.expand_filename(po.gerber_job_file, ext='gbrjob') + jobfile_writer.CreateJobFile(os.path.abspath(os.path.join(output_dir, job_fn))) def read_vals_from_po(self, po): # excludeedgelayer diff --git a/kiplot/out_gerber.py b/kiplot/out_gerber.py index 8b07d16d..6d379444 100644 --- a/kiplot/out_gerber.py +++ b/kiplot/out_gerber.py @@ -22,6 +22,8 @@ class GerberOptions(AnyLayerOptions): self.create_gerber_job_file = True """ creates a file with information about all the generated gerbers. You can use it in gerbview to load all gerbers at once """ + self.gerber_job_file = '%f-job.%x' + """ name for the gerber job file """ self.use_gerber_x2_attributes = True """ use the extended X2 format """ self.use_gerber_net_attributes = True @@ -47,6 +49,7 @@ class GerberOptions(AnyLayerOptions): po.SetIncludeGerberNetlistInfo(self.use_gerber_net_attributes) po.SetUseAuxOrigin(self.use_aux_axis_as_origin) po.SetLineWidth(FromMM(self.line_width)) + setattr(po, 'gerber_job_file', self.gerber_job_file) def read_vals_from_po(self, po): super().read_vals_from_po(po) diff --git a/tests/test_plot/test_gerber.py b/tests/test_plot/test_gerber.py index 75ac5583..e91f5451 100644 --- a/tests/test_plot/test_gerber.py +++ b/tests/test_plot/test_gerber.py @@ -48,7 +48,7 @@ def test_gerber_inner(): ctx.expect_out_file(ctx.get_gerber_filename('GND_Cu')) ctx.expect_out_file(ctx.get_gerber_filename('Signal1')) - ctx.expect_out_file(ctx.get_gerber_job_filename()) + ctx.expect_out_file(os.path.join(GERBER_DIR, 'test-'+prj+'.gbrjob')) ctx.clean_up() diff --git a/tests/yaml_samples/gerber_inner.kiplot.yaml b/tests/yaml_samples/gerber_inner.kiplot.yaml index 888846db..9d1cd3c9 100644 --- a/tests/yaml_samples/gerber_inner.kiplot.yaml +++ b/tests/yaml_samples/gerber_inner.kiplot.yaml @@ -25,6 +25,7 @@ outputs: use_protel_extensions: false gerber_precision: 4.6 create_gerber_job_file: true + gerber_job_file: 'test-%f.%x' use_gerber_x2_attributes: true use_gerber_net_attributes: false