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

Moving Layer To Top

Contributor ,
Jul 14, 2015 Jul 14, 2015

Copy link to clipboard

Copied

Can anyone help with the following.

I want to be able to count the total number of layers in the document and move the active layer to the top of the stack.

Using this code from Davide is ok but it assumes you want to move the layer to position 2

function s2t(s) { return app.stringIDToTypeID(s); };

var d1 = new ActionDescriptor();

var r1 = new ActionReference();

var r2 = new ActionReference();

r1.putEnumerated( s2t('layer'), s2t('ordinal'), s2t('targetEnum') );

d1.putReference( s2t('target'), r1 );

r2.putIndex( s2t('layer'), 2 );

d1.putReference( s2t('to'), r2 );

d1.putBoolean( s2t('adjustment'), false );

d1.putInteger( s2t('version'), 5 );

executeAction( s2t('move'), d1, DialogModes.NO );

TOPICS
Actions and scripting

Views

3.4K

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 , Jul 14, 2015 Jul 14, 2015

Rather something like this:

activeDocument.activeLayer.move( activeDocument, ElementPlacement.PLACEATBEGINNING );

Have fun

Votes

Translate

Translate
Adobe
Community Expert ,
Jul 14, 2015 Jul 14, 2015

Copy link to clipboard

Copied

Adjust the line

  1. r2.putIndex( s2t('layer'), 2 );  

accordingly.

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
Contributor ,
Jul 14, 2015 Jul 14, 2015

Copy link to clipboard

Copied

I worked that bit out, the issue I am having is trying to code a script that counts the number of layers and then move the active layer to the top.

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
Enthusiast ,
Jul 14, 2015 Jul 14, 2015

Copy link to clipboard

Copied

Something like this?

activeDocument.activeLayer.move( activeDocument.artLayers[0], ElementPlacement.PLACEBEFORE);

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 ,
Jul 14, 2015 Jul 14, 2015

Copy link to clipboard

Copied

Rather something like this:

activeDocument.activeLayer.move( activeDocument, ElementPlacement.PLACEATBEGINNING );

Have fun

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
Contributor ,
Jul 15, 2015 Jul 15, 2015

Copy link to clipboard

Copied

pixxxel schubser wrote:

Rather something like this:

  1. activeDocument.activeLayer.move( activeDocument, ElementPlacement.PLACEATBEGINNING ); 

Have fun

This worked perfectly.

For someone that is a novice, can you reccommend and reading material that explains things like ElementPlacement.PLACEATBEGINNING

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 ,
Jul 15, 2015 Jul 15, 2015

Copy link to clipboard

Copied

Glad to help you.

At the first (if you work with the ESTK = Extendscript Toolkit)

Open the Objectmodel-Viewer and search for layer. You can find methods and properties like: move.and/or moveTo Follow the links.

ESTK_Objectmodel_Viewer.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
Contributor ,
Jul 16, 2015 Jul 16, 2015

Copy link to clipboard

Copied

Thanks for the information on the object viewer.

I may be missing something but I noticed that under the browser options, I do not appear to have one for Adobe Photoshop Object Library.

I am using Extendscript Toolkit CC

Screen Shot 2015-07-16 at 11.47.22.jpg

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 ,
Jul 16, 2015 Jul 16, 2015

Copy link to clipboard

Copied

LATEST

Sorry, I can't help you in this case. I have no CS6 or CC version.

But normally there is the Photoshop Object Library (perhaps an installation problem?). I don't know.

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