Copy link to clipboard
Copied
Hi, can I write a jsx script, in ExtendScript toolkit, where I can select an object by name and Illustrator writes me his location, x and y values, in a log or popup message? Thanks in advance
Updated version of @Silly-V by accessing the item by name
#target illustrator
function test() {
var doc = app.activeDocument;
try {
var item = doc.pageItems['item_name']; //item_name is the name of the item that you see in Layers panel
alert("X: " + item.top + ", Y: " + item.left);
} catch (e) {
alert("No item with name 'item_name' exists")
}
};
test();
Copy link to clipboard
Copied
Quick answer is something like:
var item = selection[0]; // first item of selection
alert(item.position);
Copy link to clipboard
Copied
Or do you mean something like this? (Put your item's name between the quotation marks.)
alert( app.activeDocument.pageItems["your item's name"].position );
Copy link to clipboard
Copied
Here's my version of the same thing.
#target illustrator
function test(){
var doc = app.activeDocument;
var item = doc.selection[0];
alert("X: " + item.top + ", Y: " + item.left);
};
test();
Copy link to clipboard
Copied
Updated version of @Silly-V by accessing the item by name
#target illustrator
function test() {
var doc = app.activeDocument;
try {
var item = doc.pageItems['item_name']; //item_name is the name of the item that you see in Layers panel
alert("X: " + item.top + ", Y: " + item.left);
} catch (e) {
alert("No item with name 'item_name' exists")
}
};
test();