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

Is there any way to translate the whole content of the document uisng JSX script?

Community Beginner ,
Aug 08, 2018 Aug 08, 2018

Copy link to clipboard

Copied

We can move layer or a group as follows:

app.activeDocument.activeLayer.translate(100,100);

Is there any way to move whole content like above( Without iterating layer by layer )?

TOPICS
Actions and scripting

Views

1.6K

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

LEGEND , Aug 08, 2018 Aug 08, 2018

Select layer(Set)s and use this code:

function sTT(v) {return stringIDToTypeID(v)}

function mve() {

     (ref1 = new ActionReference()).putEnumerated

     (sTT('layer'), sTT('ordinal'), sTT('targetEnum'));

     (dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref1);

     dsc2 = new ActionDescriptor(); (function(v) {

          for(i = 0; i < (arr = ['horizontal', 'vertical']).length; i++) {

               dsc2.putUnitDouble(sTT(arr), sTT('pixelsUnit'), v)

          }

     })(arguments)

     dsc1.pu

...

Votes

Translate

Translate
Adobe
LEGEND ,
Aug 08, 2018 Aug 08, 2018

Copy link to clipboard

Copied

Select layer(Set)s and use this code:

function sTT(v) {return stringIDToTypeID(v)}

function mve() {

     (ref1 = new ActionReference()).putEnumerated

     (sTT('layer'), sTT('ordinal'), sTT('targetEnum'));

     (dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref1);

     dsc2 = new ActionDescriptor(); (function(v) {

          for(i = 0; i < (arr = ['horizontal', 'vertical']).length; i++) {

               dsc2.putUnitDouble(sTT(arr), sTT('pixelsUnit'), v)

          }

     })(arguments)

     dsc1.putObject(sTT('to'), sTT('offset'), dsc2)

     executeAction(sTT('move'), dsc1)

}

mve(100, 100)

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 Beginner ,
Aug 14, 2018 Aug 14, 2018

Copy link to clipboard

Copied

Thanks a lot.
Is there any way to select multiple layers, if we got references to layers?

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
LEGEND ,
Aug 14, 2018 Aug 14, 2018

Copy link to clipboard

Copied

What kind of references? btw if my code is answer for your question, mark it as correct solution

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 Beginner ,
Aug 14, 2018 Aug 14, 2018

Copy link to clipboard

Copied

What kind of references?

var layers = [app.activedocument.layers[0],app.activedocument.layers[2],app.activedocument.layers[2]]

I want to move these layers which is in layers array.

Is there any method to select the layers using script itself?

"btw if my code is answer for your question, mark it as correct solution"

Thanks a lot for the answer, But it not completely solved my question mate.

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
LEGEND ,
Aug 14, 2018 Aug 14, 2018

Copy link to clipboard

Copied

Actually I created for you a script to the problem you described in your original post. There was not anything you say now.

To select layers you can do it by Action Manager method. In contrary to Domestic Oriented Model method, layers(Set)s are counted from down. If there is background then it has 0 value, while next layers start from 1. If there is no background then first layer still has 1 value, while there is no layer with 0 value since there's no background. Regarding layerSets they have 2 values. One is closing, and one opening. Here's your additional code:

function sTT(v) {return stringIDToTypeID(v)}

for(ref = new ActionReference(), i = (arr = [1, 2, 3]).length - 1; i >= 0;) ref.putIndex(sTT('layer'), arr[i--]);

(dsc = new ActionDescriptor()).putReference(sTT('null'), ref), executeAction(sTT('select'), dsc)

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 Beginner ,
Aug 15, 2018 Aug 15, 2018

Copy link to clipboard

Copied

LATEST

Thank you very much

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 08, 2018 Aug 08, 2018

Copy link to clipboard

Copied

Image size will also change all layers sizes.

JJMack

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 Beginner ,
Aug 14, 2018 Aug 14, 2018

Copy link to clipboard

Copied

Thank you.

I want to move the layers. Not to resize.

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 14, 2018 Aug 14, 2018

Copy link to clipboard

Copied

If you want to move all layer at once. if the document has a background layer you would first need to convert it to a normal layer target all layer then move all with a single transform the only moves the targeted layers does not resize.  Part of what was the background layer will be outside the document canvas area. Layers other then Photoshop's special Background layer can be any size and position anywhere relative to the document canvas.   Photoshop Background is a special case.  It is the bottom layer in the layers stack  it Transparency is locked  the layers opacity and fill  100% the layer is canvas size and can not be moved.

You can target a layer group and move its layers  with a single translate.     You can target any number of layers throughout  the layer stack and move the all targeted layers at once with a single translate. You can target all  layer  except the background and move them with a single translate.

JJMack

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