-
Notifications
You must be signed in to change notification settings - Fork 1
バックライトLEDを配置するKiCad用スクリプト
skeletonkbd edited this page Dec 23, 2022
·
1 revision
import pcbnew
import math
def arrange() :
keys = [
[40.807724, 35.602021],
[59.857724, 35.602021],
[78.907724, 34.287539],
[99.309000, 38.456401],
[117.942712, 42.417118],
[136.576424, 46.377836],
[155.210136, 50.338554],
[141.932562, 66.991907],
[123.298850, 63.031189],
[104.665138, 59.070471],
[86.031427, 55.109754],
[65.209212, 54.652021],
[41.396712, 54.652021],
[39.713172, 73.702021],
[65.906922, 73.702021],
[86.729137, 74.733645],
[105.362849, 78.694362],
[123.996560, 82.655080],
[142.630272, 86.615798],
[147.986410, 107.229869],
[129.352699, 103.269151],
[110.718987, 99.308433],
[92.085275, 95.347715],
[71.349611, 92.752021],
[40.393361, 92.752021],
[33.249611, 111.802021],
[61.824611, 111.802021],
[113.745911, 119.427414],
[144.025693, 125.863580],
[201.674620, 122.397952],
[241.395176, 114.564415],
[286.621203, 111.802021],
[310.433703, 111.802021],
[329.483703, 111.802021],
[348.533703, 111.802021],
[329.483703, 92.752021],
[303.289953, 92.752021],
[277.096203, 92.752021],
[258.046203, 92.752021],
[237.310540, 95.347715],
[218.676828, 99.308433],
[200.043116, 103.269151],
[181.409405, 107.229869],
[186.765543, 86.615798],
[205.399254, 82.655080],
[224.032966, 78.694362],
[242.666678, 74.733645],
[263.488893, 73.702021],
[282.538893, 73.702021],
[313.495143, 73.702021],
[348.525005, 71.475001],
[346.525005, 52.425001],
[319.438439, 54.652021],
[295.625939, 54.652021],
[276.575939, 54.652021],
[257.525939, 53.911430],
[236.790276, 56.507124],
[218.156564, 60.467842],
[199.522852, 64.428560],
[180.889140, 68.389277],
[183.502535, 48.358195],
[202.136247, 44.397477],
[220.769959, 40.436759],
[239.403671, 36.476042],
[260.225885, 34.861430],
[279.275885, 35.602021],
[307.850885, 35.602021],
[344.525005, 33.375001]
]
# -12°回転させるLEDの番号
r_angled = [4,5,6,7,8,9,10,11,16,17,18,19,20,21,22,23,28,29]
# 12°回転させるLEDの番号
l_angled = [30,31,40,41,42,43,44,45,46,47,57,58,59,60,61,62,63,64]
for index, key in enumerate(keys):
ref = 'LED' + str(index + 1)
print(ref)
x = key[0]
y = key[1]
r = 0
sin12 = math.sin(math.radians(12))
cos12 = math.cos(math.radians(12))
if index + 1 in r_angled :
x=x-(1.27*4*sin12)
y=y+(1.27*4*cos12)
r = -120
elif index + 1 in l_angled :
x=x+(1.27*4*sin12)
y=y+(1.27*4*cos12)
r = 120
else:
y=y+(1.27*4)
fp = pcbnew.GetBoard().FindFootprintByReference(ref)
fp.SetPosition(pcbnew.wxPointMM(x,y))
fp.SetOrientation(r)
pcbnew.Refresh()