Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Simple Illustrator Script to Lock all Layers

New Here ,
Oct 22, 2021 Oct 22, 2021

Copy link to clipboard

Copied

Hi, I'd like to make a script in illustrator that can lock all layers in the document. I don't know javascript very well, so I'm not sure where to begin. I found this part of a script that will lock every other layer, but I really just need the script to lock every single layer. Any thoughts?

 

 

 

var aDoc = app.activeDocument;


var lc = aDoc.layers.length;
for (var i = 2; i <= lc; i+=2) {
    var curLayer = lc - i
    aDoc.layers[curLayer].locked = true;
}

 

 

TOPICS
Scripting

Views

78

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Oct 22, 2021 Oct 22, 2021
Hi, Try following var aDoc = app.activeDocument; var lc = aDoc.layers.length; for (var i = 0; i < lc; i++) { aDoc.layers[i].locked = true; }

Likes

Translate

Translate
Participant ,
Oct 22, 2021 Oct 22, 2021

Copy link to clipboard

Copied

try this 

 

var doc=app.activeDocument;
 for (i = 0; i < doc.layers.length; i++) {
          doc.layers[i].locked = true;
          }

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Oct 22, 2021 Oct 22, 2021

Copy link to clipboard

Copied

Hi,

Try following

var aDoc = app.activeDocument;
var lc = aDoc.layers.length;
for (var i = 0; i < lc; i++) {
    aDoc.layers[i].locked = true;
}

 

 

Best regards

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 22, 2021 Oct 22, 2021

Copy link to clipboard

Copied

LATEST

Thank you so much!!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines