Last active
September 4, 2015 15:07
-
-
Save JoanTheSpark/69c052a28d6c5dd41bb0 to your computer and use it in GitHub Desktop.
KiCAD 5978, Python 2.7.2, Copper Fill Polygon Drawing Script
This file contains 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
import sys, os | |
import shutil | |
import math | |
LIST_pts = [" (polygon\n (pts\n (xy "," (filled_polygon\n (pts\n (xy ",") (xy ",")\n )\n )"] | |
def FNC_poly (cntr, # (x,y) | |
radius, | |
sides, | |
startangle, | |
angle, | |
): | |
STR_data = "" | |
baseX = cntr[0] | |
baseY = cntr[1] | |
sideangle = angle / sides | |
for i in range(sides): | |
pointX = baseX + radius * math.sin(math.radians(sideangle*(i+0.5) + startangle)) | |
pointY = baseY + radius * math.cos(math.radians(sideangle*(i+0.5) + startangle)) | |
STR_data += "{:.4f}".format(pointX) + " " + "{:.4f}".format(pointY) + LIST_pts[2] | |
STR_data = STR_data[:-6] + LIST_pts[3] | |
return LIST_pts[0] + STR_data + "\n" + LIST_pts[1] + STR_data | |
if __name__ == '__main__': | |
Center = [105.0,105.0] # x/y coordinates of the centre of the pcb sheet | |
Radius = 30 # mm | |
Sides = 12 | |
StartAngle = 30.0 # degrees | |
Angle = 270.0 # degrees | |
print FNC_poly (Center, | |
Radius, | |
Sides, | |
StartAngle, | |
Angle, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment