M
M
MuhaMed2012-11-09 10:10:39
Adobe
MuhaMed, 2012-11-09 10:10:39

How to get the XY coordinates of layers in Illustrator?

I have a file with >100 layers.
For a quick export, I use a script from Arcticmill - this allows you to quickly get pictures for several extensions.
Adobe Flash allows you to lay out an image and then fold it along the same coordinates.
Question : how to extract layer position information in Illustrator?
I know that you can export to SVG and then read it, but with so many layers, more than 100K lines of code come out.
I re-read the tutorial on writing scripts from Adobe - it only says how to draw a line and an object by coordinates.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
sumnix, 2012-11-09
@MuhaMed

Try it by iterating through the layers one by one:

if (app.documents.length > 0) {
  var doc = app.activeDocument, x, y;
  app.coordinateSystem = CoordinateSystem.ARTBOARDCOORDINATESYSTEM;
  doc.activeLayer = doc.layers[0];
  doc.layers[0].hasSelectedArtwork = true;
  x = doc.selection[0].position[0];
  y = doc.selection[0].position[1];
  alert("x=" + x + " y=" + y);
}

T
Talyutin, 2012-11-09
@Talyutin

Doesn't the layer take up the entire space?

M
MuhaMed, 2012-11-09
@MuhaMed

<source lang="javascript"> if (app.documents.length > 0) { var doc = app.activeDocument; var x; var y; var t; app.coordinateSystem = CoordinateSystem.ARTBOARDCOORDINATESYSTEM; var count = doc.layers.length; var out_txt=""; for ( var i = 0; i < count; ++i) { doc.activeLayer = doc.layers[i]; doc.layers[i].hasSelectedArtwork = true; } for ( var i = 0; i < count; ++i) { x = doc.selection[i].position[0]; y = doc.selection[i].position[1]*(-1); out_txt += doc.layers[i].name + ";;x=" + x.toFixed(0) + ";;y=" + y.toFixed(0) + "\n"; } t = doc.layers[0].textFrames.add(); t.contents = out_txt; } </source>
it worked - thanks a lot!

M
MuhaMed, 2012-11-09
@MuhaMed

Result

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question