Automatic Gerbers with python file

Hi,
i have this code in a python file to do automatic Gerbers. I need add a code to do the maps files. any can help me? Tstrong texthanks

plot_plan = [
( “CuTop”, F_Cu, “Top layer” ),
( “CuBottom”, B_Cu, “Bottom layer” ),
( “PasteBottom”, B_Paste, “Paste Bottom” ),
( “PasteTop”, F_Paste, “Paste top” ),
( “SilkTop”, F_SilkS, “Silk top” ),
( “SilkBottom”, B_SilkS, “Silk top” ),
( “MaskBottom”, B_Mask, “Mask bottom” ),
( “MaskTop”, F_Mask, “Mask top” ),
( “EdgeCuts”, Edge_Cuts, “Edges” ),
]

for layer_info in plot_plan :
pctl.SetLayer(layer_info[1])
pctl.OpenPlotfile(layer_info[0], PLOT_FORMAT_GERBER, layer_info[2])
pctl.PlotLayer()

It is not clear what your exact problem is. What did you get and what did you expect? (A better formatting would also help.)

Is that all the code you have? If not, what is missing? I guess you defined pctl somewhere, what is the definition? If not, your code will most likely not work because pctl is not defined.
Uploading the complete script you use and posting the KiCad version would help us.

Next question, from where do you run the script?

Any reason why you can’t use GitHub - INTI-CMNB/KiBot: KiCad automation utility ?
It can output both gerbers and position files (I’m assuming that’s what you mean by maps).

This is a much more complicated and complex option that needs a large amount of bloat, i wouldn’t use it when there is a Python API built in KiCad that can do the job. The KiBot can do many things the Python API can’t do (not sure if this is still correct for version 7), but as long as the Python API is good enough, why use KiBot?

Because it’s a lot easier to run one pip install command and one kibot --someflag command than figuring out kicad api quirks. Granted you have to figure out --someflag too but kibot docs are much better and searchable unlike kicad api docs.

If learning api in itself isn’t the goal then just use the wheel someone built instead of reinventing it. Just my opinion.

3 Likes

Then there’s kicad-cli which comes bundled with kicad. I haven’t used it so I can’t say if it helps, but it’s worth looking at. It can be used from a script, of course.

2 Likes

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