• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Export Coordinate Value for Each Anchor in a Line

New Here ,
May 12, 2023 May 12, 2023

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.

TOPICS
Draw and design , How-to , Import and export , Scripting

Views

295

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Engaged ,
May 12, 2023 May 12, 2023

Copy link to clipboard

Copied

LATEST

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();
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines