Copy link to clipboard
Copied
I am trying to resize some art to specific dimensions. The script ran fine except for 1 file and it drove me crazy trying to find why 1 layer would not resize. I checked to make sure the layer wasn't locked:
and it looked fine. I used the line currentLayer.locked=false; to unlock any locked ones. Finally, I checked the sublevels and, sure enough, there was a level locked.
Is there a way to unlock all sublayers?
function unlock ( items ) {
var i = items.length;
if ( i ) {
while ( i-- ) {
items.locked = false;
if ( items.typename === 'GroupItem' ) {
unlock( items.pageItems );
}
else if ( items.typename === 'Layer' ) {
unlock( items.layers );
unlock( items.pageItems );
}
}
}
}
unlock( activeDocument.layers );
Copy link to clipboard
Copied
As an option:
function unlockedSubLayers ( layers ) {
var i = layers.length;
if ( i ) {
while ( i-- ) {
layers.locked = false;
unlockedSubLayers( layers.layers );
}
}
}
unlockedSubLayers( activeDocument.layers );
Copy link to clipboard
Copied
I had tried something very similar and it didn't work.
Copy link to clipboard
Copied
You're right. Could explain why my unlock function didn't work. New to javascript. How would I unlock a locked raster item?
Copy link to clipboard
Copied
Matter of fact that doesn't look like a locked sub-layer, it looks like a locked raster item!
Copy link to clipboard
Copied
function unlock ( items ) {
var i = items.length;
if ( i ) {
while ( i-- ) {
items.locked = false;
if ( items.typename === 'GroupItem' ) {
unlock( items.pageItems );
}
else if ( items.typename === 'Layer' ) {
unlock( items.layers );
unlock( items.pageItems );
}
}
}
}
unlock( activeDocument.layers );
Copy link to clipboard
Copied
Thanks alexander and silly-v.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now