# COMMUNITY : FORUMS : TECH

In Eagle, I'm trying to make a ring that is divided into 18 equal sections. However, I'm not sure how to do it. The only idea I can think of is manually creating each polygon, but there has to be an easier way. I've tried taking the ring and drawing lines through it in both the restrict & kepout layers, it doesn't work, though.

sort by: active | newest | oldest
westfw9 years ago
EAGLE has polar coordinates available from the command line, which is probably the easiest way to do something like this: grid mm; arc ccw 0.5 (p 25 0) (p 25 180) (p 25 19); arc ccw 0.5 (p 25 20) (p 25 200) (p 25 39); arc ccw 0.5 (p 25 40) (p 25 220) (p 25 59); (and etc. Or write a ULP.)
zachninme (author)  westfw9 years ago
Thanks! I'll have to play around with it, though.
zachninme (author)  zachninme9 years ago
I wrote a python script to generate the code. This got me pretty close:
`for x in range(18):    n = 20 * x    print "arc ccw 5 (p 7 %s) (p 7 %s) (p 7 %s);" % (n,(180 + n),(n+18))`
Don't mock the power of quick-coding! Ugly gets you really far sometimes! :P
If anyone is referencing this. Change the "print" line accordingly:
replace...
5 with the width of the segments
7 (all 3) with the radius
n+18 makes 2mm separations (20-2 = 18)
If you want more/less segments, adjust range(18) accordingly. However, you will need to replace 20 * x such that the 2 numbers multiplied by each other is 360.
9 years ago
BTW; that's brilliant. I've seen a lot of people over in the EAGLE forum that never seem to make that leap of intuition to get to "I can create EAGLE scripts using some other convenient programming! (or even a fancy text editor!)"
zachninme (author)  zachninme9 years ago
This is what I finnally ended up using:
`grid mm;arc ccw 11 (p 9 0) (p 9 180) (p 9 18);arc ccw 11 (p 9 20) (p 9 200) (p 9 38);arc ccw 11 (p 9 40) (p 9 220) (p 9 58);arc ccw 11 (p 9 60) (p 9 240) (p 9 78);arc ccw 11 (p 9 80) (p 9 260) (p 9 98);arc ccw 11 (p 9 100) (p 9 280) (p 9 118);arc ccw 11 (p 9 120) (p 9 300) (p 9 138);arc ccw 11 (p 9 140) (p 9 320) (p 9 158);arc ccw 11 (p 9 160) (p 9 340) (p 9 178);arc ccw 11 (p 9 180) (p 9 360) (p 9 198);arc ccw 11 (p 9 200) (p 9 380) (p 9 218);arc ccw 11 (p 9 220) (p 9 400) (p 9 238);arc ccw 11 (p 9 240) (p 9 420) (p 9 258);arc ccw 11 (p 9 260) (p 9 440) (p 9 278);arc ccw 11 (p 9 280) (p 9 460) (p 9 298);arc ccw 11 (p 9 300) (p 9 480) (p 9 318);arc ccw 11 (p 9 320) (p 9 500) (p 9 338);arc ccw 11 (p 9 340) (p 9 520) (p 9 358);`
westfw9 years ago
For completeness, here's some code in EAGLE's "User Language" to do the same thing, somewhat more prettified than Zachinme's python. From an "advanced user" point of view, I REALLY like having both scripts and ULPs available to augment EAGLE's capabilities.
`string grid = "grid mm;";	// units and grid settingstring center = "(00 00)";	// coordinates of center pointstring cap = "flat";		// arc line cap style (flat or round.)				//   (rounded segments will overlap!)int segments = 18;		// number of segmentsint gap = 2;			// gap between segments (in degrees)int width = 13;			// line width for arcint radius = 20;		// circle radius/* code */int eachsegment = 360/segments;int i;string h, cmd ="";/* main */cmd = grid + "change cap " + cap + ";\n";sprintf(h, "mark %s;", center); cmd +=h;for (i=0; i < segments; i++) {  int arcstart = i * eachsegment;  sprintf(h, "arc ccw %d (p %d %d) (p %d %d) (p %d %d);\n",	width,	radius, arcstart,	radius, arcstart + 180,	radius, arcstart + eachsegment - gap);  cmd += h;}exit(cmd);`
zachninme (author)  westfw9 years ago
Ooh...Very vewy nice!