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 );
Rather something like this:
activeDocument.activeLayer.move( activeDocument, ElementPlacement.PLACEATBEGINNING );
Have fun
Copy link to clipboard
Copied
Adjust the line
r2.putIndex( s2t('layer'), 2 );
accordingly.
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.
Copy link to clipboard
Copied
Something like this?
activeDocument.activeLayer.move( activeDocument.artLayers[0], ElementPlacement.PLACEBEFORE);
Copy link to clipboard
Copied
Rather something like this:
activeDocument.activeLayer.move( activeDocument, ElementPlacement.PLACEATBEGINNING );
Have fun
Copy link to clipboard
Copied
pixxxel schubser wrote:
Rather something like this:
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
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.
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
Copy link to clipboard
Copied
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.