@bradido's answer is helpful, it is incomplete.
It seems Illustrator has different coordinate systems: an overall document coordinate system and a second based on the currently-active artboard (you may have several defined but only one is 'active' at a time.) One has the origin at the centre of the document while the other has the origin at top-left. Also it's Y values increase upwards.
It is wise to first check for the coordinate system using the app.coordinateSystem
property, and if needed, there is a conversion function (doc.convertCoordinate
) which handles the offset from the centre.
Here's an snippet which demonstrates how to retrieve x,y values for symbols in Illustrator, which can later be used in actionscript (using the coordinate system conversion):
var doc = app.activeDocument;
var sel = doc.selection;
var selLen = sel.length;
var code = 'var pointsOnMap:Vector.<Vec> = Vector.<Vec>([';
for(var i = 0 ; i < selLen ; i++){
var pos = doc.convertCoordinate(sel[i].position, app.coordinateSystem, CoordinateSystem.ARTBOARDCOORDINATESYSTEM);
code += 'new Vec('+(pos[0] + (sel[i].width * .5)).toFixed(2) + ' , ' + Math.abs((pos[1] - (sel[i].height*.5))).toFixed(2); // Math.abs(pos-height) - same for both coord systems ?
if(i < selLen-1) code += '),';
else code += ')]);pointsOnMap.fixed=true;';
}
$.writeln(code);
For more details, see this thread on the Adobe Forums.