Skip to content

Instantly share code, notes, and snippets.

@cg-method
Last active September 6, 2019 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cg-method/7d18c6f5c4c5cd82f51b190b01a5c3e0 to your computer and use it in GitHub Desktop.
Save cg-method/7d18c6f5c4c5cd82f51b190b01a5c3e0 to your computer and use it in GitHub Desktop.
【Photoshop】全てのロックを解除するスクリプト
function unlockLayers(){
var topLayer = app.activeDocument.layers[0];
app.activeDocument.activeLayer = topLayer;
do {
unlockLayer();
selectLayerBelow();
} while(topLayer != app.activeDocument.activeLayer);
function unlockLayer() {
if(app.activeDocument.activeLayer.isBackgroundLayer ) app.activeDocument.activeLayer.name = '背景';
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 );
}
}
unlockLayers()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment