I have a board with around 10,000 LEDs on it and I need each one rotating through 90 degrees. I started by doing them by hand (around 800 of them), but found the scripting interface and thought I could use that. No matter what I do I can’t get the syntax of the angle parameter to the footprint.rotate function right. Here’s what I have:
import sys
import pcbnew
b = pcbnew.GetBoard()
for m in b.GetFootprints():
s = m.GetReference()
if (s[0] == ‘D’) :
if s >= “D818” :
m.Rotate(pcbnew.VECTOR2I(0, 0), pcbnew.EDA_ANGLE.m_Angle90))
I have tried VECTOR2D in place of m_Angle90, but that complains about not knowing what a VECTOR2D is!!!
Perfect, and I learned a bit of Python in the process
Resulting code was:
for m in b.GetFootprints():
ref = m.GetReference()
if (ref[0] == 'D') :
if (int(ref[1:]) > 818) :
print ("* Module: %s"%ref)
m.SetOrientationDegrees(0)
Turns out they were already at 90 degrees, so needed to set them to 0
Thanks for your help
Paul
(edit by qu1ck: code formatting to preserve whitespace, critically important in python)