Copy link to clipboard
Copied
Hi,
I have a line that is constructed by 30 anchor points. When I hover my mouse on top of each anchor, I can see the (X, Y) coordinate values for each of them. Is there a way that I can output a table or list from Illustrator that contains the coordinate values for all 30 anchor points? I need those values for some mathematical calculation, so that's why I come up with this question.
Thank you for any input.
Copy link to clipboard
Copied
This is just a quick example and could be way more robust but at least it gets you headed in the right direction.
var doc = app.activeDocument;
var sel = doc.selection;
// create a string to hold the anchor info
var str = "";
// iterate over each item in the selection
var item, point;
for (var i = 0; i < sel.length; i++) {
item = sel[i];
// only work with PathItems
if (item.typename == "PathItem") {
// append each point anchor info to the string
for (var n = 0; n < item.pathPoints.length; n++) {
point = item.pathPoints[n];
str += "Point " + n + ": " + point.anchor + "\n";
}
}
}
if (str.length > 0) {
// setup file info
var fpath = Folder.desktop;
var fname = "points.txt";
var f = new File(fpath + "/" + fname);
// write the points info to a text file
try {
f.encoding = "UTF-8";
f.open("w");
f.write(str);
f.close();
} catch (e) {
alert("Error writing file!\n" + e);
}
alert("File saved!\n" + f);
// open the file
f.execute();
}