Beenden
  • Globale Community
    • Sprache:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

Progressively move layers PSCC 2015

Engagiert ,
Feb 03, 2017 Feb 03, 2017

I am considering a script to progressively move up all selected layers by 100px.

The number of selected layers decreases by one until the of selected layer equals one.

The number of layers in the PSD file is not constant.

The layer kind is constant.

Not sure what is the simplest solution to accomplish the script behavior.

Is a for loop the correct tool for this scripting behavior?

1- select all layers

2- deselect top layer

3- move up all selected layers 100px

4- deselect top layer from selected layers group

5- move up all selected layers 100px

6- repeat step 4

5- repeat step 5

progressively-deslect-layer.jpg

THEMEN
Aktionen und Skripte
917
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines

correct answers 1 richtige Antwort

Community Expert , Feb 04, 2017 Feb 04, 2017

#target photoshop

app.preferences.rulerUnits = Units.PIXELS;

var doc =activeDocument

var moveAmt = -100

var moveCurrent = -100

var numLayers = doc.layers.length

for(var i=1;i<numLayers;i++){

    doc.activeLayer = doc.layers

    try{

        doc.activeLayer.translate(0,moveCurrent)

    }

    catch(e){}

    moveCurrent+=moveAmt

    }

Übersetzen
Adobe
Community Expert ,
Feb 04, 2017 Feb 04, 2017

Yes a loop would be needed. You could do it the way you described, or it might be better just to loop through each layer and move each layer by a move distance variable then increase that variable number by the amount you want for each iteration of the loop. Selecting multiple layers and deselecting them can be a bit of a pain, not to mention you're moving multiple layers numerous times, which might slow down your script.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Engagiert ,
Feb 04, 2017 Feb 04, 2017

Thanks for your help.

I understand what I need with the script but don't know how to ask the question in scripting terms.

The top layer in the layer stack does not move

Each loop iteration the selected layer moves up -100px * the number of remaining loop iterations.

How do I calculate the number of remaining iterations and what is the syntax to move layers?

progrssively-move-lyrs.jpg

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Engagiert ,
Feb 04, 2017 Feb 04, 2017
AKTUELL

Thank you! the script works well, much simpler and elegant solution than what I had in mind.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Feb 04, 2017 Feb 04, 2017

#target photoshop

app.preferences.rulerUnits = Units.PIXELS;

var doc =activeDocument

var moveAmt = -100

var moveCurrent = -100

var numLayers = doc.layers.length

for(var i=1;i<numLayers;i++){

    doc.activeLayer = doc.layers

    try{

        doc.activeLayer.translate(0,moveCurrent)

    }

    catch(e){}

    moveCurrent+=moveAmt

    }

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines