/* add coords to marks */
var items = selection;
// alert('selection.lenght: ' + selection.length);
if (items.length>0) {
for (i=0; i<items.length; i++) {
var x = getX(items[i]);
var y = getY(items[i]);
// alert(i + ': x' + x + ' y' + y);
markPosition (items[i]);
}
} else { alert('Select objects to add coordinates!');}
function markPosition (item) {
var x = getX(item);
var y = getY(item);
var textRef = activeDocument.textFrames.add();
textRef.position = Array (mm2pt(x+5),mm2pt(y-5));
textRef.textRange.characterAttributes.size = 50;
textRef.contents ='x' + x + " y" + y;
}
function mm2pt (number) {
return (number*2.8346);
}
function pt2mm (number) {
return (number/2.8346);
}
function getX(item) {
var X = pt2mm (item.position[0]);
var W = pt2mm (item.width);
return(Math.round((X + W/2)*10)/10);
}
function getY(item) {
var Y = pt2mm (item.position[1]);
var H = pt2mm (item.height);
return(Math.round((Y - H/2)*10)/10);
}