Copy link to clipboard
Copied
Hi All,
I'm new to InDesign (and Scripting) and I really need your help. I'm sorry to start off on an 'ask'. Hopefully I'll be able to be helpful to others over time.
I'm trying to automate some monotonous tasks, and I'm writing (or scrounging) code to perform a few simple jobs in sequence in a script.
The current task I'm trying to automate is 'lock all layers'.
Sounds pretty simple, but I literally have no idea what I'm doing.
The script will have to find all the layers in a file (there will be many, varied names and numbers of layers) and lock them. Nothing else (yet).
I've found loads of instances of 'unlock all layers' scripts and I've trued changing their 'true' values to 'false' at the end, but it was a stab in the dark.
I appreciate all help and advice. I tried looking for a glossary of JavaScript terms but I didn't really know how to ask google properly. HTML is about my speed at the moment, but hopefully JavaScript should start making sense soon.
Cheers
Matt
Hi Matt,
using ExtendScript ( JavaScript 😞
1. Adress a document, here an example for the active one.
The assumption here is that the script will be running from InDesign's Scripts panel so that object app automatically denotes the running version of InDesign:
var doc = app.activeDocument;
2. Adress all layers in that document and set the value for the property locked for all layers to true.
doc.layers.everyItem().locked = true;
That's it…
Here a great resource compiled by Jongware for looking after obj
...Copy link to clipboard
Copied
Hi Matt,
using ExtendScript ( JavaScript 😞
1. Adress a document, here an example for the active one.
The assumption here is that the script will be running from InDesign's Scripts panel so that object app automatically denotes the running version of InDesign:
var doc = app.activeDocument;
2. Adress all layers in that document and set the value for the property locked for all layers to true.
doc.layers.everyItem().locked = true;
That's it…
Here a great resource compiled by Jongware for looking after objects, properties and methods for InDesign, Illustrator and PhotoShop:
The iChm files you can download there are searchable.
Newer versions of DOM documentation compiled by Gregor Fellenz:
https://www.indesignjs.de/extendscriptAPI/indesign13/#about.html
There is a dedicated scripting forum for InDesign:
How to save script code for ExtendScript scripts, install and organize scripts:
Indiscripts :: Indiscripts for Dummies
Also check the Help menu of the ExtendScript Toolkit app (ESTK) that is installed with every InDesign installation.
Regards,
Uwe
Copy link to clipboard
Copied
Thank you so much, this is a great answer.
It worked and you've helped me to understand. I really appreciate it.
I had a problem for a while getting an error and I noticed it was always in Line 15, no matter what I put in line 15.
It seems like hitting save in ExtendScript doesn't do a live update of the scrip in ID, or it might just be my work machine, which I think is haunted by the previous user.
Again, thank you so much. You've saved about a weeks worth of work for me.
Next I'm going to work out how to make it 'Save As'.
Wish me luck
Copy link to clipboard
Copied
I had a problem for a while getting an error and I noticed it was always in Line 15, no matter what I put in line 15.
It seems like hitting save in ExtendScript doesn't do a live update of the scrip in ID, or it might just be my work machine, which I think is haunted by the previous user.
When you try to run a script from ESTK make sure you target the application.
So this throws an error:
But this doesn't