Answered
Does layer exist?
Is there a in-built way in Photoshop scripting to return if a layer exists or not? Bearing in mind that there may be duplicate layer names so getByName isn't what I'm after.
function does_layer_exist(id)
{
var originalSelectedLayer = app.activeDocument.activeLayer;
try
{
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putIdentifier(charIDToTypeID('Lyr '), id);
desc1.putReference(charIDToTypeID('null'), ref1);
executeAction(charIDToTypeID('slct'), desc1, DialogModes.NO);
app.activeDocument.activeLayervar = originalSelectedLayer;
return true;
}
catch(eek)
{
return false;
}
}
This works, but I'm just wondering if there is an in-built method to call.
Curious, me, you see.
