• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script location of object

Community Beginner ,
Mar 11, 2021 Mar 11, 2021

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

 
 
 
 
TOPICS
Scripting , Tools

Views

288

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 11, 2021 Mar 11, 2021

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();

 

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

Quick answer is something like:

var item = selection[0]; // first item of selection
alert(item.position);

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 11, 2021 Mar 11, 2021

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 );

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Mar 11, 2021 Mar 11, 2021

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();

Silly-V_0-1615497852135.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

LATEST

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();

 

Best regards

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines