Add preflight options, but they don't wowork

This commit is contained in:
John Beard 2018-06-02 17:21:47 +01:00
parent ac2ceedae2
commit 02f3db1a2d
4 changed files with 35 additions and 6 deletions

View File

@ -2,6 +2,12 @@
kiplot:
version: 1
preflight:
# one day....
check_zone_fills: false
run_drc: false
outputs:
- name: 'gerbers'

View File

@ -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)

View File

@ -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 [

View File

@ -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)