@@ -60,12 +60,16 @@ def _output_is_layer(self, output):
6060 PCfg .OutputOptions .GERBER ,
6161 PCfg .OutputOptions .POSTSCRIPT ,
6262 PCfg .OutputOptions .DXF ,
63+ PCfg .OutputOptions .SVG ,
64+ PCfg .OutputOptions .PDF ,
65+ PCfg .OutputOptions .HPGL ,
6366 ]
6467
6568 def _output_is_drill (self , output ):
6669
6770 return output .options .type in [
6871 PCfg .OutputOptions .EXCELLON ,
72+ PCfg .OutputOptions .GERB_DRILL ,
6973 ]
7074
7175 def _get_layer_plot_format (self , output ):
@@ -129,31 +133,57 @@ def _do_layer_plot(self, board, plot_ctrl, output):
129133 plot_ctrl .OpenPlotfile (suffix , plot_format , desc )
130134
131135 logging .debug ("Plotting layer {} to {}" .format (
132- layer .layer , plot_ctrl .GetPlotFileName ()))
136+ layer .layer , plot_ctrl .GetPlotFileName ()))
133137 plot_ctrl .PlotLayer ()
134138
135- def _do_drill_plot (self , board , plot_ctrl , output ):
136-
137- to = output .options .type_options
139+ def _configure_excellon_drill_writer (self , board , offset , options ):
138140
139- outdir = plot_ctrl . GetPlotOptions (). GetOutputDirectory ( )
141+ drill_writer = pcbnew . EXCELLON_WRITER ( board )
140142
141- drlwriter = pcbnew . EXCELLON_WRITER ( board )
143+ to = options . type_options
142144
143145 mirror_y = to .mirror_y_axis
144146 minimal_header = to .minimal_header
145147
148+ merge_npth = to .pth_and_npth_single_file
149+ zeros_format = pcbnew .EXCELLON_WRITER .DECIMAL_FORMAT
150+
151+ drill_writer .SetOptions (mirror_y , minimal_header , offset , merge_npth )
152+ drill_writer .SetFormat (to .metric_units , zeros_format )
153+
154+ return drill_writer
155+
156+ def _configure_gerber_drill_writer (self , board , offset , options ):
157+
158+ drill_writer = pcbnew .GERBER_WRITER (board )
159+
160+ # hard coded in UI?
161+ drill_writer .SetFormat (5 )
162+ drill_writer .SetOptions (offset )
163+
164+ return drill_writer
165+
166+ def _do_drill_plot (self , board , plot_ctrl , output ):
167+
168+ to = output .options .type_options
169+
170+ outdir = plot_ctrl .GetPlotOptions ().GetOutputDirectory ()
171+
146172 # dialog_gendrill.cpp:357
147173 if to .use_aux_axis_as_origin :
148174 offset = board .GetAuxOrigin ()
149175 else :
150176 offset = pcbnew .wxPoint (0 , 0 )
151177
152- merge_npth = to .pth_and_npth_single_file
153- zeros_format = pcbnew .EXCELLON_WRITER .DECIMAL_FORMAT
154-
155- drlwriter .SetOptions (mirror_y , minimal_header , offset , merge_npth )
156- drlwriter .SetFormat (to .metric_units , zeros_format )
178+ if output .options .type == PCfg .OutputOptions .EXCELLON :
179+ drill_writer = self ._configure_excellon_drill_writer (
180+ board , offset , output .options )
181+ elif output .options .type == PCfg .OutputOptions .GERB_DRILL :
182+ drill_writer = self ._configure_gerber_drill_writer (
183+ board , offset , output .options )
184+ else :
185+ raise error .PlotError ("Can't make a writer for type {}"
186+ .format (output .options .type ))
157187
158188 gen_drill = True
159189 gen_map = to .generate_map
@@ -164,19 +194,19 @@ def _do_drill_plot(self, board, plot_ctrl, output):
164194 .format (outdir ))
165195
166196 if gen_map :
167- drlwriter .SetMapFileFormat (to .map_options .type )
197+ drill_writer .SetMapFileFormat (to .map_options .type )
168198 logging .debug ("Generating drill map type {} in {}"
169199 .format (to .map_options .type , outdir ))
170200
171- drlwriter .CreateDrillandMapFilesSet (outdir , gen_drill , gen_map )
201+ drill_writer .CreateDrillandMapFilesSet (outdir , gen_drill , gen_map )
172202
173203 if gen_report :
174204 drill_report_file = os .path .join (outdir ,
175205 to .report_options .filename )
176206 logging .debug ("Generating drill report: {}"
177207 .format (drill_report_file ))
178208
179- drlwriter .GenDrillReportFile (drill_report_file )
209+ drill_writer .GenDrillReportFile (drill_report_file )
180210
181211 def _configure_gerber_opts (self , po , output ):
182212
0 commit comments