-
Notifications
You must be signed in to change notification settings - Fork 3
/
Toggle Layer Lock.js
30 lines (24 loc) · 1.03 KB
/
Toggle Layer Lock.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* Toggle Layer Lock
Toggles the lock on layers in the active document whose names are specified in the file name.
HOW TO USE:
- edit this file's name to include the name of the Layers you want to lock, separated by spaces
NOTE:
The layer names are CASE SENSITIVE
EXAMPLE:
My InDesign document has layers named Text, Images, and Guides.
I want this script to only lock Text and Images, so I rename this file to:
Toggle Layer Lock Text Images.js
- run this script normally
- more instructions here: https://github.com/saraoswald/Manga-Scripts#how-to-use-scripts-in-indesign
*/
var layers = app.activeDocument.layers;
var fileName = app.activeScript.name;
var baseName = 'Toggle%20Layer%20Lock%20';
var names = fileName.replace(baseName, '').replace('.js', '').split('%20');
for (var i = 0; i < names.length; i++) {
toggleLock(layers.itemByName(names[i]));
}
function toggleLock(layer) {
if (!layer.isValid) return;
layer.locked = !layer.locked;
}