KiCad script does not take effect

Hallo Forum,

I’m new to python scripting in KiCad. I was trying to make all references in a board invisible. In contrast, all values should be visible and on the “front silk screen layer”.
The script, I wrote for that (see below) as two problems:

a) Nothing I change seems to take effect in PCBNew

b) I get an exception on setting the visibilty (solved!)

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/confus/sync/prog/kicad/espdev/scripttest/", line 21, in <module>
  File "/usr/lib/python2.7/dist-packages/", line 2697, in SetVisible
    return _pcbnew.EDA_TEXT_SetVisible(self, aVisible)
TypeError: in method 'EDA_TEXT_SetVisible', argument 2 of type 'bool'

I have now idea, why. I run my script from within the scripting console using the command execfile('/home/confus/sync/prog/kicad/espdev/scripttest/'). Of course I have my layout open in PCBNew and run the console from the same window.

Here is the content of my script file:

from __future__ import print_function
from pcbnew import *

pcb = GetBoard()
mods =  pcb.m_Modules

for mod in mods:
    print(mod.GetReference(), mod.GetValue())
    val = mod.Value()
    val.SetLayer(37) # Layer 37 = F.SilkS
    except Exception, e:

And here is the version information for my dev-build of KiCad4:

What am I doing wrong?

I’m not able to test this suggestion, but try …


Yes, that was it, stupid me. Thank you!

From the exception, “true” was actually my first attempt at fixing. Of course I was forgetting, that python uses upper case for the first letter and thought “well, can’t be it, after all ‘true’ didn’t help”.

Stil the problem that nothing changes in PCB remains (yes I hit “B” and “F3” to redraw).

Hi, con-f-use. Have you tried running your script in both Legacy (F9) and OpenGL (F11) modes? I had a script that had no visible effect unless run in Legacy mode. This might help identify if the problem is in your script or in KiCad itself.