Copy link to clipboard
Copied
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?
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Perfect!
Thank you!
Copy link to clipboard
Copied
You're welcome 🙂
Copy link to clipboard
Copied
Can you explain how to do the same for a specific layer with a name?
Copy link to clipboard
Copied
Hi @Zebra
Is it single layer with that specific name or multiple layers with that name?
Copy link to clipboard
Copied
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)
}
Copy link to clipboard
Copied
Thanks it works perfect 👌
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
woow you are amazing man Thanks
Find more inspiration, events, and resources on the new Adobe Community
Explore Now