Vcut (Vscore) from Python pcbnew

If someone is doing scripted panelization, I’ve recently had panels manufactured with v-cut as vertical separation of boards, and routed slots for horizontal separation, this worked well. Just for reference, the code draws the V-cut in the pcbnew module in the Eco1.User layer, plots the Gerber, and changes the output file to Vcut following the Gerber X2 file format. And as I said, this was handled without issue by the manufacturer. The relevant code is as follows:

##### Generate gerbers for Vcut
if Eco1_as_Vcut:
  pctl.SetLayer(pcbnew.Eco1_User)
  pctl.OpenPlotfile("Vcut", pcbnew.PLOT_FORMAT_GERBER, "Vcut")
  pctl.PlotLayer()
  pctl.ClosePlot()
  # Change Eco1.User to Vcut inside Gerber X2 file, see
  # https://www.ucamco.com/files/downloads/file/81/the_gerber_file_format_specification.pdf
  with open(pctl.GetPlotFileName(), "r+") as f: 
    contents=f.readlines()
    for i,line in enumerate(contents):
      if line=="%TF.FileFunction,Other,ECO1*%\n":
        contents[i]="%TF.FileFunction,Vcut*%\n"
    f.seek(0)
    f.truncate()
    f.write("".join(contents))

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.