Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/kiplot/kiplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

try:
import pcbnew
from pcbnew import GERBER_JOBFILE_WRITER
except ImportError:
logging.error("Failed to import pcbnew Python module."
" Do you need to add it to PYTHONPATH?")
Expand Down Expand Up @@ -48,14 +49,13 @@ def plot(self, brd_file):
self._configure_output_dir(pc, op)

if self._output_is_layer(op):
self._do_layer_plot(board, pc, op)
self._do_layer_plot(board, pc, op, brd_file)
elif self._output_is_drill(op):
self._do_drill_plot(board, pc, op)
else:
raise PlotError("Don't know how to plot type {}"
.format(op.options.type))

pc.ClosePlot()

def _preflight_checks(self, board):

Expand Down Expand Up @@ -107,14 +107,22 @@ def _get_layer_plot_format(self, output):
raise ValueError("Don't know how to translate plot type: {}"
.format(output.options.type))

def _do_layer_plot(self, board, plot_ctrl, output):
def _do_layer_plot(self, board, plot_ctrl, output, file_name):

# set up plot options for the whole output
self._configure_plot_ctrl(plot_ctrl, output)

po = plot_ctrl.GetPlotOptions()
layer_cnt = board.GetCopperLayerCount()

# Gerber Job files aren't automagically created
# We need to assist KiCad
create_job = po.GetCreateGerberJobFile()
if create_job:
jobfile_writer = GERBER_JOBFILE_WRITER(board)

plot_ctrl.SetColorMode(True)

# plot every layer in the output
for l in output.layers:

Expand Down Expand Up @@ -148,6 +156,17 @@ def _do_layer_plot(self, board, plot_ctrl, output):
logging.debug("Plotting layer {} to {}".format(
layer.layer, plot_ctrl.GetPlotFileName()))
plot_ctrl.PlotLayer()
plot_ctrl.ClosePlot()
if create_job:
jobfile_writer.AddGbrFile(layer.layer,
os.path.basename(plot_ctrl.GetPlotFileName()));

if create_job:
base_fn = os.path.dirname(plot_ctrl.GetPlotFileName())+'/'+os.path.basename(file_name)
base_fn = os.path.splitext(base_fn)[0]
job_fn = base_fn+'-job.gbrjob'
jobfile_writer.CreateJobFile(job_fn)


def _configure_excellon_drill_writer(self, board, offset, options):

Expand Down