Copy link to clipboard
Copied
Hello, everyone,
I am using ExtendScript to move groups of objects into certain locations on an Illustrator art board. It had been working up until now, when I had to change the positions. Now when I try to run the script, the positions of the objects are off by about 1.417 points.
I have an action in Illustrator that sets the origin point to the top left corner, and then runs the javaScript. Here is the code:
it looks like 1.41, 1.41 is where the 0,0 is. How's the Action setting the Ruler?
The issue with pageOrigin and rulerOrigin is that those are "relative" positions, they depend on the the size of the document, the 0,0 position and/or the coordinate system.
Use the ArtboardRect instead, that will give you the left/top coordinate regardless of the other variables.
var r = app.activeDocument.artboards[0].artboardRect;
var left = r[0];
var top = r[1];
var alpha = app.activeDocument.layers.getByN
...
Copy link to clipboard
Copied
it looks like 1.41, 1.41 is where the 0,0 is. How's the Action setting the Ruler?
The issue with pageOrigin and rulerOrigin is that those are "relative" positions, they depend on the the size of the document, the 0,0 position and/or the coordinate system.
Use the ArtboardRect instead, that will give you the left/top coordinate regardless of the other variables.
var r = app.activeDocument.artboards[0].artboardRect;
var left = r[0];
var top = r[1];
var alpha = app.activeDocument.layers.getByName('Layer 2').groupItems[0];
alpha.position = [left, top];
Copy link to clipboard
Copied
Thanks, CarlosCanto, that did the trick. I was having the origin point set by the extendScript, but the selected object's reference point changed to the upper left corner.
Thanks, again!