So, I`d like to output a rounded equilateral triangle in Gerber format.
The first method I tried was to pick a large triangular aperture (%ADD11P,8X3*%
, that is) and draw a small closed arc, a.k.a. circle, with it:
%FSLAX26Y26*%
%MOMM*%
G01*
%LPD*%
%ADD10C,1*%
%ADD11P,8X3*%
D11*
X00000000Y00000000D02*
G03*
G75*
I01000000J01000000D01*
M02*
However, the reference Gerber viewer throws a rather peculiar error while trying to interpret that file:
Arc with a non-circular aperture found. This is invalid.
Okay, I thought, but I can still approximate a circle with lines, right? Let`s try drawing a line:
%FSLAX26Y26*%
%MOMM*%
G01*
%LPD*%
%ADD10C,1*%
%ADD11P,8X3*%
D11*
X00000000Y00000000D02*
X11000000Y07000000D01*
M02*
And again, the reference app doesn`t seem to like what I`m trying to do:
Draw with an invalid aperture 11 emulated. Review resulting image.
And only if I correct my aperture definition to become a diamond instead of a triangle (%ADD11P,8X4*%
) no errors get thrown.
Am I doing something wrong? Is drawing arcs or lines with triangular apertures documented as incorrect in the standard somewhere?
Naturally, I know I can compute 3 points and draw 3 segments between them using a circle and then fill the interior with a polygon, but I`d really like to avoid that. The task this one is a part of implies drawing multiple triangles with different orientations which can easily be set using the aperture angle parameter.
…Well, preliminary solution found:
%FSLAX26Y26*%
%MOMM*%
G01*
%LPD*%
%AM_my_own_triangle*
$5=$1*
$6=$2x$1*
$7=0.8660254x$5*
4,1,3,$5,0,-0.5x($5+$6),$7,-0.5x($5+$6),-$7,$5,0,$3+$4*
4,1,3,$5,0,-0.5x($5+$6),$7,-0.5x($5+$6),-$7,$5,0,$3+$4+120*
4,1,3,$5,0,-0.5x($5+$6),$7,-0.5x($5+$6),-$7,$5,0,$3+$4+240*
1,1,$6,$5,0,$3+$4*
1,1,$6,$5,0,$3+$4+120*
1,1,$6,$5,0,$3+$4+240*%
%ADD10_my_own_triangle,100x0.1x0x0*%
D10*X00000000Y00000000D03*
M02*
Here I make extensive use of the so-called Aperture Macro definitions. AMs can be rotated independently, see $3+$4+*
, and support variables in arithmetic expressions.
This seems to be it, so if in a week`s time nothing less inelegant appears in answers, I`m going to answer the question myself.