Hello All,
I want to add silkscreen text to some components programmatically while hiding the default reference silkscreen text.
I am not sure how to do this. Can anyone tell me how to extend/change my existing code:
board = pcbnew.LoadBoard(bfn)
for a in range(6):
s=board.FindFootprintByReference("SW"+str(a+1))
s.SetProperty('Silk',"MyCustomSilk"+str(a+1))
s.Reference().SetVisible(False) # Hide the "SWx" reference
...
I am not sure how to make the MyCustomSilk[x] show up as silkscreen.
s.Reference().Clone()
<pcbnew.EDA_ITEM; proxy of <Swig Object of type 'EDA_ITEM *' at 0x7f6b4fd8ef30> >
m=s.Reference().Clone()
m.SetText("MyCustomSilk")
Traceback (most recent call last):
File "/usr/lib/python3.8/code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "/usr/lib/python3/dist-packages/pcbnew.py", line 1659, in <lambda>
__getattr__ = lambda self, name: _swig_getattr(self, EDA_ITEM, name)
File "/usr/lib/python3/dist-packages/pcbnew.py", line 80, in _swig_getattr
raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
AttributeError: 'EDA_ITEM' object has no attribute 'SetText'
>>> my_text = pcbnew.FP_TEXT(s.Reference())
Traceback (most recent call last):
File "/usr/lib/python3.8/code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "/usr/lib/python3/dist-packages/pcbnew.py", line 17952, in __init__
this = _pcbnew.new_FP_TEXT(*args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_FP_TEXT'.
Possible C/C++ prototypes are:
FP_TEXT::FP_TEXT(FOOTPRINT *,FP_TEXT::TEXT_TYPE)
FP_TEXT::FP_TEXT(FOOTPRINT *)
No copy constructor then. Don’t you just love how “consistent” the API is. Creating a new one it is my_text = pcbnew.FP_TEXT(s).
You may have to set things like layer and visibility manually.