Copy link to clipboard
Copied
I wish How to Select HFame Layer in Template
displayDialogs = DialogModes.NO; // OFF
var layer = app.activeDocument.activeLayer;
var layerName = layer.name;
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
//for (var i = 0; i < numOfLayers-1 ; i++)
//{
// get a referenec to each layer as we loop over them
//var thisLayer = srcDoc.layers[i];
if(layerName=="HFrame")
{
alert("H");
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName(cTID('Lyr '), "HFrame");
desc1.putReference(cTID('null'), ref1);
desc1.putBoolean(cTID('MkVs'), false);
var list1 = new ActionList();
list1.putInteger(21);
desc1.putList(cTID('LyrI'), list1);
executeAction(cTID('slct'), desc1, DialogModes.NO);
//break;
}
else
{
alert("V");
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putName(cTID('Lyr '), "VFrame");
desc1.putReference(cTID('null'), ref1);
desc1.putBoolean(cTID('MkVs'), false);
var list1 = new ActionList();
list1.putInteger(21);
desc1.putList(cTID('LyrI'), list1);
executeAction(cTID('slct'), desc1, DialogModes.NO);
//break;
}
// }
If Condition is false , I Can't Select HFrame in My Template.
Thanks in Advance
Try the following snippet
try{
var lyr = app.documents[0].layers.getByName("HFrame")
app.documents[0].activeLayer = lyr
}
catch(e){alert("Could not locate layer")}
If you have multiple layers with the same name the above code will select only the first one in the collection.
-Manan
Copy link to clipboard
Copied
Try the following snippet
try{
var lyr = app.documents[0].layers.getByName("HFrame")
app.documents[0].activeLayer = lyr
}
catch(e){alert("Could not locate layer")}
If you have multiple layers with the same name the above code will select only the first one in the collection.
-Manan
Copy link to clipboard
Copied
Thank you both for your suggestions. If Layer 2 is selected, the function UnlockLayers selects Layer 1 when the script runs. When the scripts run again and Layer 1 reams selected. Is it possible to select Layer 2 when the script runs a second time? Basically acting like a layer switch.