Created
January 3, 2020 17:23
-
-
Save hsgw/8500153bdd90e7db81eb11e61b0b1628 to your computer and use it in GitHub Desktop.
kicad circular layout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The center of circle is grid origin | |
import pcbnew | |
import math | |
def circular(refList, angleStart, angleEnd, radiusMM): | |
board = pcbnew.GetBoard() | |
modules = board.GetModules() | |
center = board.GetGridOrigin() | |
angleStep = float((angleEnd - angleStart)) / (len(refList)-1) | |
radius = radiusMM * 1000000 | |
index = 0 | |
for ref in refList: | |
for module in modules: | |
if module.GetReference() != ref: | |
continue | |
angle = math.radians(angleStart + angleStep * index) | |
dest = pcbnew.wxPoint(radius * math.cos(angle) + center.x, radius * math.sin(angle) + center.y) | |
module.SetPosition(dest) | |
module.SetOrientation((angleStart + angleStep * index) * -10) | |
index += 1 | |
break | |
else: | |
print("Not found: " + ref) | |
# circular(["LED" + str(i) for i in range(1,16)], 140, 400, 15) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment