Drawing lines with ESTK is a nightmare
Friends, Romans, countrymen, lend me your ears! I come to bash Adobe [not plain Shakespeare]
What strange mathematics is necessary to get the lines drawn as they should: all from a centre out at steps of 30°?
In the FM coordinate system y goes from top to bottom. I have found that the bounding box (aka dimensions) of the object is disconnected from the end points of the line. As You can see from the diagram below, created lines in quadrants II and IV are flipped up/down - after the drawing routine has been left!
How to cope with this strange happening!

// --- Create lines at all 30° angles - FM coordinate system in cm
#target framemaker
main ();
function main () {
var j, oDoc, oFrame, x0, x1, y0, y1, length, angle, oLine, oPoints = [];
CM = 1857713, pi = Math.PI;
oDoc = app.ActiveDoc;
oFrame = oDoc.FirstSelectedGraphicInDoc;
if (!oFrame.ObjectValid()) {
Alert("Select an anchored frame and try again.", Constants.FF_ALERT_CONTINUE_WARN);
return;
}
for (j= 0; j < 8; j++) {
length = 3;
angle = pi/4 * j; // 0, 30°, 60° … 330°
x0 = 6;
y0 = 4;
x1 = x0 + length * Math.cos(angle);
y1 = y0 + length * Math.sin(angle);
oLine = CreateLine (oDoc, oFrame, x0, y0, x1, y1);
oPoints = oLine.Points; // after drawing lines in quadrants II and IV are flipped up/down!
$.writeln ("b xo/y0 = " + oPoints[0].x/CM + "\t" + oPoints[0].y/CM );
$.writeln ("b x1/y1 = " + oPoints[1].x/CM + "\t" + oPoints[1].y/CM );
}
} //--- end main
function CreateLine (oDoc, oFrame, x0, y0, x1, y1) {
// x, y are the location of endpoints [cm]; FM-coordinate system!
var j, oLine, oPoints = [], oPoint=[], width, height,
CM = 1857713, FRMAKER5819 = 8192;
oPoints.length = 0;
oLine = oDoc.NewLine(oFrame);
oPoint0 = new Point(),
oPoint0.x = x0*CM; oPoint0.y = y0*CM;
oPoints.push(oPoint0);
oPoint1 = new Point(),
oPoint1.x = x1*CM; oPoint1.y = y1*CM;
oPoints.push(oPoint1);
width = x1 - x0;
height = y1 - y0;
oLine.Width = Math.abs(width)* CM;
oLine.Height = Math.abs(height)* CM;
if (Math.abs(width)* CM < FRMAKER5819) {oLine.Width = FRMAKER5819};
if (Math.abs(height)* CM < FRMAKER5819) {oLine.Height = FRMAKER5819};
// --- quadrants in FM coordinate system ---------
if (x0 <= x1 & y0 <= y1) {$.writeln ("\n------------ quadrant I");
oLine.LocX = x0 * CM; oLine.LocY = y0 * CM;
}
if (x0 > x1 & y0 <= y1) {$.writeln ("\n------------ quadrant II");
oLine.LocX = x1 * CM; oLine.LocY = y0 * CM;
}
if (x0 > x1 & y0 > y1) {$.writeln ("\n------------ quadrant III");
oLine.LocX = x1 * CM; oLine.LocY = y1 * CM;
}
if (x0 <= x1 & y0 > y1) { $.writeln ("\n------------ quadrant IV");
oLine.LocX = x0 * CM; oLine.LocY = y1 * CM;
}
$.writeln ("a xo/y0 = " + oPoints[0].x/CM + "\t" + oPoints[0].y/CM );
$.writeln ("a x1/y1 = " + oPoints[1].x/CM + "\t" + oPoints[1].y/CM );
oLine.BorderWidth = 0.05*CM; // Stroke-width
oLine.Color = oDoc.GetNamedColor("Magenta");
//$.bp(true);
return oLine;
} //--- end CreateLine
The constant FRMAKER5819 is there to cope with the error described in the respective bug report.


