Skip to content

Commit 02f3db1

Browse files
committed
Add preflight options, but they don't wowork
1 parent ac2ceed commit 02f3db1

File tree

4 files changed

+35
-6
lines changed

4 files changed

+35
-6
lines changed

docs/samples/generic_plot.kiplot.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
kiplot:
33
version: 1
44

5+
preflight:
6+
7+
# one day....
8+
check_zone_fills: false
9+
run_drc: false
10+
511
outputs:
612

713
- name: 'gerbers'

kiplot/config_reader.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,16 @@ def _parse_output(self, o_obj):
437437

438438
return o_cfg
439439

440+
def _parse_preflight(self, pf, cfg):
441+
442+
logging.debug("Parsing preflight options: {}".format(pf))
443+
444+
if 'check_zone_fills' in pf:
445+
cfg.check_zone_fills = pf['check_zone_fills']
446+
447+
if 'run_drc' in pf:
448+
cfg.run_drc = pf['run_drc']
449+
440450
def read(self, fstream):
441451
"""
442452
Read a file object into a config object
@@ -452,13 +462,11 @@ def read(self, fstream):
452462

453463
self._check_version(data)
454464

455-
try:
456-
outdir = data['options']['basedir']
457-
except KeyError:
458-
outdir = ""
459-
460465
cfg = PC.PlotConfig()
461466

467+
if 'preflight' in data:
468+
self._parse_preflight(data['preflight'], cfg)
469+
462470
for o in data['outputs']:
463471

464472
op_cfg = self._parse_output(o)

kiplot/kiplot.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ def __init__(self, cfg):
2929
self.cfg = cfg
3030

3131
def plot(self, brd_file):
32+
3233
logging.debug("Starting plot of board {}".format(brd_file))
3334

3435
board = pcbnew.LoadBoard(brd_file)
3536

3637
logging.debug("Board loaded")
3738

39+
self._preflight_checks(board)
40+
3841
for op in self.cfg.outputs:
3942

4043
logging.debug("Processing output: {}".format(op.name))
@@ -54,6 +57,16 @@ def plot(self, brd_file):
5457

5558
pc.ClosePlot()
5659

60+
def _preflight_checks(self, board):
61+
62+
logging.debug("Preflight checks")
63+
64+
if self.cfg.check_zone_fills:
65+
raise PlotError("Not sure if Python scripts can do zone check!")
66+
67+
if self.cfg.run_drc:
68+
raise PlotError("Not sure if Python scripts can run DRC!")
69+
5770
def _output_is_layer(self, output):
5871

5972
return output.options.type in [

kiplot/plot_config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ def line_width(self, value):
6868
"""
6969
if self._supports_line_width:
7070
self._line_width = pcbnew.FromMM(value)
71-
print("Set LW %d" % self._line_width)
7271
else:
7372
raise KiPlotConfigurationError(
7473
"This output doesn't support setting line width")
@@ -441,6 +440,9 @@ def __init__(self):
441440
self._outputs = []
442441
self.outdir = None
443442

443+
self.check_zone_fills = False
444+
self.run_drc = False
445+
444446
def add_output(self, new_op):
445447
self._outputs.append(new_op)
446448

0 commit comments

Comments
 (0)