Instantly share code, notes, and snippets.

What would you like to do?
Unlock all layers in a PhotoShop document.
var topLayer = app.activeDocument.layers[0];
app.activeDocument.activeLayer = topLayer;
do {
} while(topLayer != app.activeDocument.activeLayer);
function unlockLayer() {
if(app.activeDocument.activeLayer.isBackgroundLayer ) = 'From Background';
if(app.activeDocument.activeLayer.allLocked) app.activeDocument.activeLayer.allLocked = false;
if(app.activeDocument.activeLayer.pixelsLocked && app.activeDocument.activeLayer.kind != LayerKind.TEXT) app.activeDocument.activeLayer.pixelsLocked = false;
if(app.activeDocument.activeLayer.positionLocked) app.activeDocument.activeLayer.positionLocked = false;
if(app.activeDocument.activeLayer.transparentPixelsLocked && app.activeDocument.activeLayer.kind != LayerKind.TEXT) app.activeDocument.activeLayer.transparentPixelsLocked = false;
function selectLayerBelow() {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Bckw" ) );
desc.putReference( charIDToTypeID( "null" ), ref );
desc.putBoolean( charIDToTypeID( "MkVs" ), false );
executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );

This comment has been minimized.

Copy link

jardicc commented Mar 28, 2016

This doesn't work for nesting layers locking (artboard feature) and for layers which are not visible :-)


This comment has been minimized.

Copy link

salitha93 commented Aug 14, 2017

This is not work for me:

app.activeDocument.activeLayer.transparentPixelsLocked = false

error: Adobe Photoshop CC 2014

app.activeDocument.activeLayer.transparentPixelsLocked = false
Error: General Photoshop error occurred. This functionality may not be available in this version of Photoshop.

  • The command "Set" is not currently available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment