Hello everyone,
I'm trying to write a script that needs to check the uniformity of each layer and rename each layer accordingly.
Apparently I managed to do that but it happens that if no layer is selected the script won't work.
So I came up with this solution (this is just a section of the script):
#target photoshop
if (app.documents.length) {
var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
var docRef = app.activeDocument;
//DODGY WAY TO SELECT TOP LAYER
var ghostLyr = docRef.artLayers.add()
ghostLyr.move (docRef, ElementPlacement.PLACEATBEGINNING)
docRef.activeLayer.remove()
//DODGY WAY TO SELECT BACKGROUND
var ghostLyr = docRef.artLayers.add()
ghostLyr.move (docRef, ElementPlacement.PLACEATEND)
docRef.activeLayer.remove()
}
So basically I create an empty layer, place it on top or bottom and immediately delete it, so the layer beneath automatically selects.
Any better idea?
It looks like a workaround to me, it works, but it is... dodgy.
Thanks for all the help!
MD