Skip to content

Instantly share code, notes, and snippets.

@Arahnoid
Created April 1, 2014 20:27
Show Gist options
  • Save Arahnoid/9922452 to your computer and use it in GitHub Desktop.
Save Arahnoid/9922452 to your computer and use it in GitHub Desktop.
Make layer active by name
/**
* makeLayerActiveByName
* @param string nm Layer name]
* @return
* @usage selects layer by name and mak it active
* @env Photoshop
*/
function makeLayerActiveByName(nm) {
function cTID(s) { return app.charIDToTypeID(s); };
try {
var desc5 = new ActionDescriptor();
var ref4 = new ActionReference();
ref4.putName( cTID('Lyr '), nm);
desc5.putReference( cTID('null'), ref4 );
desc5.putBoolean( cTID('MkVs'), false );
executeAction( cTID('slct'), desc5, DialogModes.NO );
return true;
} catch (e) {
return false;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment