Select Layer by Name (with or without objects)?
I appropriated a script from this thread (thank you, pixxxel schubser).
It works as long as "myLayer" contains object(s) (even if they are locked and hidden). How can I change it to select the layer whether it has artwork or not?
I tried setting "hasSelectedArtwork" to "false", but no cigar.
var aDoc = app.activeDocument;
aDoc.selection = null;
try {
// be sure that top level layer with name "FINGERPRINT" with sublayer with name "Fingerprints" exists
var myLayer = aDoc.layers.getByName('FINGERPRINT').layers.getByName('Fingerprints');
myLayer.hasSelectedArtwork = true;
}
catch (e) {
alert("the layer doesn't exist");
// do whatever you want
}
Here's a sample file. The script will select "Fingerprints" layer unless the layer is empty.