Skip to main content
New Participant
May 23, 2019
Answered

Unlocked all layers and nested layers

  • May 23, 2019
  • 2 replies
  • 1138 views

Hi guys, I've been trying to come up with a script that unlocks all layers, groups and nested layers in a PSD file, but unsuccessfully.

I think it should be simple, but I can't make it work. And I need to achieve this by script, so later I can do some more tweaking.

example of layers:

Any help??

thanks so much!!!

D

This topic has been closed for replies.
Correct answer r-bin

app.runMenuItem(stringIDToTypeID("selectAllLayers"));

var d = new ActionDescriptor();

var r = new ActionReference();

r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

d.putReference(stringIDToTypeID("null"), r);

var d1 = new ActionDescriptor();

var d2 = new ActionDescriptor();

d2.putBoolean(stringIDToTypeID("protectNone"), true);

d1.putObject(stringIDToTypeID("layerLocking"), stringIDToTypeID("layerLocking"), d2);

d.putObject(stringIDToTypeID("to"), stringIDToTypeID("layer"), d1);

executeAction(stringIDToTypeID("set"), d, DialogModes.NO);

app.runMenuItem(stringIDToTypeID("selectNoLayers"));

2 replies

r-binCorrect answer
Brainiac
May 23, 2019

app.runMenuItem(stringIDToTypeID("selectAllLayers"));

var d = new ActionDescriptor();

var r = new ActionReference();

r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

d.putReference(stringIDToTypeID("null"), r);

var d1 = new ActionDescriptor();

var d2 = new ActionDescriptor();

d2.putBoolean(stringIDToTypeID("protectNone"), true);

d1.putObject(stringIDToTypeID("layerLocking"), stringIDToTypeID("layerLocking"), d2);

d.putObject(stringIDToTypeID("to"), stringIDToTypeID("layer"), d1);

executeAction(stringIDToTypeID("set"), d, DialogModes.NO);

app.runMenuItem(stringIDToTypeID("selectNoLayers"));

dvivasAuthor
New Participant
May 24, 2019

My god, you're a genius!

that worked flawlessly!

By looking at your code, it was definitely out of my league, I need to learn and practice more

Thanks so much!!!

Chuck Uebele
Community Expert
May 23, 2019

Use scriptListener to get the code to unlock the layers. Then you need to create a recursive function to cycle through all the layers and layersets.