I am writing the selected layers indexes into an selectedLayers array. Then I am using this:
function getLayerNameByIndex(idx) { var ref = new ActionReference(); ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "Nm " )); ref.putIndex( charIDToTypeID( "Lyr " ), idx ); return executeActionGet(ref).getString(charIDToTypeID( "Nm " ));;
}
to get the layer name by its index.
Then I am using it like this:
var layer = doc.layers.getByName(getLayerNameByIndex(selectedLayers[i]));
to get the layer in a variable. NOTE: I don't want to select the layer, I just want to get it into a variable, so I can do this:
layer.textItem.contents = "blahblah";
Everything of the above works fine currently, but I want to improve it.
So my question would be following: can I get the layer by its ID? Something like doc.layers.getById (instead of doc.layers.getByName)?