← Back to team overview

kicad-developers team mailing list archive

Python scripting - drills are impossible to plot

 

Summary: The Python scripting API does not have a way to produce drill
  hits as output when plotting, such as SVG or PDF output.

Background:
  I'm attempting to write a python script to help me generate a "paper
  test" plot. My previous email ("Python scripting plot
  options .SetColor() get ignored") has an attached example.

  This example was created by the help of gEDA's gerbv, though I expect
  KiCad's own gerbview could also assist. One thing it required doing
  was adding the drill file as a layer, when using the gerber viewer to
  then export a combined SVG file of the result.

I have attempted to create a python script (see also attached on my
previous email) to help me create this image. I've now got fairly
close, but one thing I'm having trouble with is drill hits.

The script works by repeated calls to .SetLayer() to choose a layer to
work on then .PlotLayer(). The layers it draws are Edge_Cuts, and the
SilkS and Mask layers of either front or back. There's no layer
associated with drill hits.

Because there's no "Drills" layer, I can't do something such as:

  pctl.SetLayer(Drills)
  popt.SetColor(BLACK)
  pctl.PlotLayer()

In fact, reading over the actual plotting logic that's distributed
around pcbnew/plot_board_layers.cpp, mostly within the function
PlotOneBoardLayer(), I think it is impossible to plot drills at all, if
you don't draw any copper layers. Every single non-copper layer's code
contains the line

  plotOpt.SetDrillMarksType( PCB_PLOT_PARAMS::NO_DRILL_SHAPE );

So for me it appears impossible that I could draw these.

At the C++ level, it appears it would be quite easy:

  BRDITEMS_PLOTTER itemplotter(plotter, board, popt);
  plotter->SetColor(BLACK);
  itemplotter.PlotDrillMarks();

However, I don't see a wrapping of BRDITEMS_PLOTTER at the Python
scripting layer on

  http://ci.kicad-pcb.org/job/kicad-doxygen/ws/build/pcbnew/doxygen-python/html/namespacepcbnew.html

Would it be possible for some kind of scriptable API to be added? I'd
like to plot the drill hits as solid black discs. It doesn't have to be
a "fake" layer like my Drills example above; I'd be quite happy to
simply have a method at the Python layer for

  pctl.PlotDrillMarks()

-- 
Paul "LeoNerd" Evans

leonerd@xxxxxxxxxxxxxx
http://www.leonerd.org.uk/  |  https://metacpan.org/author/PEVANS

Attachment: pgpkO8ds4W8vS.pgp
Description: OpenPGP digital signature


Follow ups