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

How to set coordinates for newly pasted item

Contributor ,
Aug 19, 2021 Aug 19, 2021

Copy link to clipboard

Copied

I currently have an item (a group) that is copied with scripting.  

I paste this item into a specific layer like so:

    var mainTemplateLayer = aDoc.layers.getByName("Placement" + plcIx);
    aDoc.activeLayer = mainTemplateLayer;
          app.paste();

the layer mainTemplateLayer already has an item there (a box).

How can I get the pasted item only and set the top and left coordinates?

TOPICS
Scripting

Views

254

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 , Aug 19, 2021 Aug 19, 2021

Try something like this

// your group is already copied
app.selection = null;
app.paste();
var sel = app.selection[0];
alert (sel.left);
alert (sel.top);
sel.left = 0;
sel.top = -200;

 

Votes

Translate

Translate
Adobe
Community Expert ,
Aug 19, 2021 Aug 19, 2021

Copy link to clipboard

Copied

Try something like this

// your group is already copied
app.selection = null;
app.paste();
var sel = app.selection[0];
alert (sel.left);
alert (sel.top);
sel.left = 0;
sel.top = -200;

 

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 ,
Aug 20, 2021 Aug 20, 2021

Copy link to clipboard

Copied

Similarly (since a pasted item is the topmost pageItem):

 

app.paste();
app.activeDocument.pageItems[0].position = [50, - 50];

 

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 ,
Aug 20, 2021 Aug 20, 2021

Copy link to clipboard

Copied

LATEST

Careful though. You can paste more than one item. In that case, this method would only move the top item and leave the rest of the pasted items behind.

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