Add gerber drills

This commit is contained in:
John Beard 2018-06-02 16:45:15 +01:00
parent d3b331e3ad
commit 6dfbaea4e0
3 changed files with 62 additions and 14 deletions

View File

@ -52,6 +52,13 @@ outputs:
map: map:
type: 'pdf' type: 'pdf'
- name: gerber drills
comment: "Gerber drill files"
type: gerb_drill
dir: gerberdir
options:
use_aux_axis_as_origin: false
- name: postscript - name: postscript
comment: "Postscript files" comment: "Postscript files"
type: ps type: ps

View File

@ -60,12 +60,16 @@ class Plotter(object):
PCfg.OutputOptions.GERBER, PCfg.OutputOptions.GERBER,
PCfg.OutputOptions.POSTSCRIPT, PCfg.OutputOptions.POSTSCRIPT,
PCfg.OutputOptions.DXF, PCfg.OutputOptions.DXF,
PCfg.OutputOptions.SVG,
PCfg.OutputOptions.PDF,
PCfg.OutputOptions.HPGL,
] ]
def _output_is_drill(self, output): def _output_is_drill(self, output):
return output.options.type in [ return output.options.type in [
PCfg.OutputOptions.EXCELLON, PCfg.OutputOptions.EXCELLON,
PCfg.OutputOptions.GERB_DRILL,
] ]
def _get_layer_plot_format(self, output): def _get_layer_plot_format(self, output):
@ -129,31 +133,57 @@ class Plotter(object):
plot_ctrl.OpenPlotfile(suffix, plot_format, desc) plot_ctrl.OpenPlotfile(suffix, plot_format, desc)
logging.debug("Plotting layer {} to {}".format( logging.debug("Plotting layer {} to {}".format(
layer.layer, plot_ctrl.GetPlotFileName())) layer.layer, plot_ctrl.GetPlotFileName()))
plot_ctrl.PlotLayer() plot_ctrl.PlotLayer()
def _configure_excellon_drill_writer(self, board, offset, options):
drill_writer = pcbnew.EXCELLON_WRITER(board)
to = options.type_options
mirror_y = to.mirror_y_axis
minimal_header = to.minimal_header
merge_npth = to.pth_and_npth_single_file
zeros_format = pcbnew.EXCELLON_WRITER.DECIMAL_FORMAT
drill_writer.SetOptions(mirror_y, minimal_header, offset, merge_npth)
drill_writer.SetFormat(to.metric_units, zeros_format)
return drill_writer
def _configure_gerber_drill_writer(self, board, offset, options):
drill_writer = pcbnew.GERBER_WRITER(board)
# hard coded in UI?
drill_writer.SetFormat(5)
drill_writer.SetOptions(offset)
return drill_writer
def _do_drill_plot(self, board, plot_ctrl, output): def _do_drill_plot(self, board, plot_ctrl, output):
to = output.options.type_options to = output.options.type_options
outdir = plot_ctrl.GetPlotOptions().GetOutputDirectory() outdir = plot_ctrl.GetPlotOptions().GetOutputDirectory()
drlwriter = pcbnew.EXCELLON_WRITER(board)
mirror_y = to.mirror_y_axis
minimal_header = to.minimal_header
# dialog_gendrill.cpp:357 # dialog_gendrill.cpp:357
if to.use_aux_axis_as_origin: if to.use_aux_axis_as_origin:
offset = board.GetAuxOrigin() offset = board.GetAuxOrigin()
else: else:
offset = pcbnew.wxPoint(0, 0) offset = pcbnew.wxPoint(0, 0)
merge_npth = to.pth_and_npth_single_file if output.options.type == PCfg.OutputOptions.EXCELLON:
zeros_format = pcbnew.EXCELLON_WRITER.DECIMAL_FORMAT drill_writer = self._configure_excellon_drill_writer(
board, offset, output.options)
drlwriter.SetOptions(mirror_y, minimal_header, offset, merge_npth) elif output.options.type == PCfg.OutputOptions.GERB_DRILL:
drlwriter.SetFormat(to.metric_units, zeros_format) drill_writer = self._configure_gerber_drill_writer(
board, offset, output.options)
else:
raise error.PlotError("Can't make a writer for type {}"
.format(output.options.type))
gen_drill = True gen_drill = True
gen_map = to.generate_map gen_map = to.generate_map
@ -164,11 +194,11 @@ class Plotter(object):
.format(outdir)) .format(outdir))
if gen_map: if gen_map:
drlwriter.SetMapFileFormat(to.map_options.type) drill_writer.SetMapFileFormat(to.map_options.type)
logging.debug("Generating drill map type {} in {}" logging.debug("Generating drill map type {} in {}"
.format(to.map_options.type, outdir)) .format(to.map_options.type, outdir))
drlwriter.CreateDrillandMapFilesSet(outdir, gen_drill, gen_map) drill_writer.CreateDrillandMapFilesSet(outdir, gen_drill, gen_map)
if gen_report: if gen_report:
drill_report_file = os.path.join(outdir, drill_report_file = os.path.join(outdir,
@ -176,7 +206,7 @@ class Plotter(object):
logging.debug("Generating drill report: {}" logging.debug("Generating drill report: {}"
.format(drill_report_file)) .format(drill_report_file))
drlwriter.GenDrillReportFile(drill_report_file) drill_writer.GenDrillReportFile(drill_report_file)
def _configure_gerber_opts(self, po, output): def _configure_gerber_opts(self, po, output):

View File

@ -313,6 +313,8 @@ class DrillOptions(TypeOptions):
super(DrillOptions, self).__init__() super(DrillOptions, self).__init__()
self.use_aux_axis_as_origin = False
self.map_options = None self.map_options = None
self.report_options = None self.report_options = None
@ -336,6 +338,13 @@ class ExcellonOptions(DrillOptions):
self.mirror_y_axis = False self.mirror_y_axis = False
class GerberDrillOptions(DrillOptions):
def __init__(self):
super(GerberDrillOptions, self).__init__()
class DrillReportOptions(object): class DrillReportOptions(object):
def __init__(self): def __init__(self):
@ -377,6 +386,8 @@ class OutputOptions(object):
self.type_options = PdfOptions() self.type_options = PdfOptions()
elif otype == self.EXCELLON: elif otype == self.EXCELLON:
self.type_options = ExcellonOptions() self.type_options = ExcellonOptions()
elif otype == self.GERB_DRILL:
self.type_options = GerberDrillOptions()
else: else:
self.type_options = None self.type_options = None