Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Javascript to Unlock All Layers

New Here ,
May 21, 2020 May 21, 2020

I can't seem to find a simple javascript to "Unlock All Layers" for illustrator.

I just want to litterally unlock all layers 🙂

 

Any help out there? 

TOPICS
Scripting
3.8K
Translate
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

Community Expert , May 21, 2020 May 21, 2020

Hi,

Please try following snippet to unlock all layers and sublayers in Illustartor

 

function unlockLayers(_layers) {
    for (var i = 0; i < _layers.length; i++) {
        if (_layers[i].locked) {
            _layers[i].locked = false;
        }
        if (_layers[i].layers.length)
            unlockLayers(_layers[i].layers);
    }
}
unlockLayers(app.activeDocument.layers);

 

Let us know if this helps

 

Translate
Adobe
Community Expert ,
May 21, 2020 May 21, 2020

Hi,

Please try following snippet to unlock all layers and sublayers in Illustartor

 

function unlockLayers(_layers) {
    for (var i = 0; i < _layers.length; i++) {
        if (_layers[i].locked) {
            _layers[i].locked = false;
        }
        if (_layers[i].layers.length)
            unlockLayers(_layers[i].layers);
    }
}
unlockLayers(app.activeDocument.layers);

 

Let us know if this helps

 

Best regards
Translate
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 ,
May 22, 2020 May 22, 2020

Perfect!

Thank you! 

Translate
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
Community Expert ,
May 22, 2020 May 22, 2020

You're welcome 🙂

Best regards
Translate
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 ,
Jul 27, 2021 Jul 27, 2021

Can you explain how to do the same for a specific layer with a name? 

 

Translate
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
Community Expert ,
Jul 27, 2021 Jul 27, 2021

Hi @Zebra 

Is it single layer with that specific name or multiple layers with that name?

Best regards
Translate
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
Community Expert ,
Jul 27, 2021 Jul 27, 2021

@Zebra 

Following snippet will unlock all layers with name "Test"

function unlockLayers(_layers) {
    for (var i = 0; i < _layers.length; i++) {
        if (_layers[i].locked && _layers[i].name == _layerName) {
            _layers[i].locked = false;
        }
        if (_layers[i].layers.length)
            unlockLayers(_layers[i].layers);
    }
}
var _layerName = "Test";
unlockLayers(app.activeDocument.layers);

 

And if there is a single layer at top level with name "Test" then there is no need to traverse all the layers. In this case following code will be sufficient.

var doc = app.activeDocument;
try {
    var _layer = doc.layers[_layerName];
    if (_layer.locked)
        _layer.locked = false;
} catch (e) {
    alert("No layer exists with name : " + _layerName)
}
Best regards
Translate
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 ,
Jul 27, 2021 Jul 27, 2021

Thanks it works perfect 👌

 

Translate
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 ,
Aug 12, 2021 Aug 12, 2021

Can you please explain this in laymans terms on how to accomplish this so I have access to my fonts to finish setting up an SVG file for cutting on vinyl.

I have no idea about scripting or coding.  Please help me access my fonts.

 

error reads: Some text was on a locked layer and the font could not be replaced

 

 

Darlene5E58_0-1628795347659.png

 

Translate
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
Explorer ,
Nov 27, 2021 Nov 27, 2021
LATEST

woow you are amazing man Thanks

 

Translate
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