diff --git a/docs/samples/generic_plot.kiplot.yaml b/docs/samples/generic_plot.kiplot.yaml index eed3be33..a57fd480 100644 --- a/docs/samples/generic_plot.kiplot.yaml +++ b/docs/samples/generic_plot.kiplot.yaml @@ -2,6 +2,12 @@ kiplot: version: 1 +preflight: + + # one day.... + check_zone_fills: false + run_drc: false + outputs: - name: 'gerbers' diff --git a/kiplot/config_reader.py b/kiplot/config_reader.py index 8b00b710..5924796f 100644 --- a/kiplot/config_reader.py +++ b/kiplot/config_reader.py @@ -437,6 +437,16 @@ class CfgYamlReader(CfgReader): return o_cfg + def _parse_preflight(self, pf, cfg): + + logging.debug("Parsing preflight options: {}".format(pf)) + + if 'check_zone_fills' in pf: + cfg.check_zone_fills = pf['check_zone_fills'] + + if 'run_drc' in pf: + cfg.run_drc = pf['run_drc'] + def read(self, fstream): """ Read a file object into a config object @@ -452,13 +462,11 @@ class CfgYamlReader(CfgReader): self._check_version(data) - try: - outdir = data['options']['basedir'] - except KeyError: - outdir = "" - cfg = PC.PlotConfig() + if 'preflight' in data: + self._parse_preflight(data['preflight'], cfg) + for o in data['outputs']: op_cfg = self._parse_output(o) diff --git a/kiplot/kiplot.py b/kiplot/kiplot.py index 12e5de2c..4700acaf 100644 --- a/kiplot/kiplot.py +++ b/kiplot/kiplot.py @@ -29,12 +29,15 @@ class Plotter(object): self.cfg = cfg def plot(self, brd_file): + logging.debug("Starting plot of board {}".format(brd_file)) board = pcbnew.LoadBoard(brd_file) logging.debug("Board loaded") + self._preflight_checks(board) + for op in self.cfg.outputs: logging.debug("Processing output: {}".format(op.name)) @@ -54,6 +57,16 @@ class Plotter(object): pc.ClosePlot() + def _preflight_checks(self, board): + + logging.debug("Preflight checks") + + if self.cfg.check_zone_fills: + raise PlotError("Not sure if Python scripts can do zone check!") + + if self.cfg.run_drc: + raise PlotError("Not sure if Python scripts can run DRC!") + def _output_is_layer(self, output): return output.options.type in [ diff --git a/kiplot/plot_config.py b/kiplot/plot_config.py index 6d324dc0..784fb293 100644 --- a/kiplot/plot_config.py +++ b/kiplot/plot_config.py @@ -68,7 +68,6 @@ class LayerOptions(TypeOptions): """ if self._supports_line_width: self._line_width = pcbnew.FromMM(value) - print("Set LW %d" % self._line_width) else: raise KiPlotConfigurationError( "This output doesn't support setting line width") @@ -441,6 +440,9 @@ class PlotConfig(object): self._outputs = [] self.outdir = None + self.check_zone_fills = False + self.run_drc = False + def add_output(self, new_op): self._outputs.append(new_op)