Absolute artboard coordinates

Coordinate of top left corner of artboard on canvas unknown
Create temporary rectangles
var abCoord = getArtboardCoord(0);function getArtboardCoord(idx) {
var doc = app.activeDocument,
aLayer = doc.activeLayer,
thisAbRect = doc.artboards[idx].artboardRect;

var fakePath = aLayer.pathItems.add(),
cnvsDelta = 1 + ((fakePath.position[0] * 2 - 16384) - (fakePath.position[1] * 2 + 16384)) / 2,
pathPos = [fakePath.position[0] - cnvsDelta, fakePath.position[1] + cnvsDelta],
cnvsPath = aLayer.pathItems.rectangle(pathPos[0], pathPos[1], 300, 300);
cnvsPath.filled = false;
cnvsPath.stroked = false;

// Create a rectangle with the same size as the artboard
var top = thisAbRect[1],
left = thisAbRect[0],
width = thisAbRect[2] - thisAbRect[0],
height = thisAbRect[1] - thisAbRect[3];

var abPath = aLayer.pathItems.rectangle(top, left, width, height);
abPath.stroked = false;
abPath.filled = false;
var absLeft = Math.floor(abPath.position[0] - cnvsPath.position[0]),
absTop = Math.floor(cnvsPath.position[1] - abPath.position[1]),
absBottom = absTop + height,
absRight = absLeft + width;

fakePath.remove();
abPath.remove();
cnvsPath.remove();
redraw();
return { 'left': absLeft, 'right': absRight, 'top': absTop, 'bottom': absBottom };
}
Demo

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store