Set visible layers using pcbnew and python

I am trying to set only the copper layer visible in my kicad file. I use the following code, then export the footprints and convert them to svg. When I look at the svg file, it looks like all of the layers are still turned on. How can I fix the code?

f_cu_layer_id = board.GetLayerID("F.Cu")
lset = pcbnew.LSET()
lset.addLayer(f_cu_layer_id)
board.SetVisibleLayers(lset)

After I set the visible layers, I also ran the below code and it showed that the board only had the F.Cu layer visible (layer 0). However, the layers are still visible in the GUI.

lset2 = board.GetVisibleLayers()
lset2.Contains(1) #substitute for any other layer id

You probably need to reload the board in the editor to see those changes.

I am trying to do this programmatically, is there a way to reload the image using python?

If pcbnew.Refresh() doesn’t do it, then no.

I’ll try. Appreciate it!

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