Change the rulers original point to center of selected object
I am trying to write a JavaScript that changes the rulers orgin point to the center of the current selected object.
Here is my code:
var doc = app.activeDocument;
var sel = doc.selection;
if (sel.length > 0) {
var obj = sel[0];
var objBounds = obj.geometricBounds;
var objX = (objBounds[0] + objBounds[2]) / 2;
var objY = (objBounds[1] + objBounds[3]) / 2;
doc.rulerOrigin = [objX, objY];
}
It quits out on this line:
var sel = doc.selection;
Error:
Underfined is not an object
Can someone point me in the right direction.
Thank You
