Copy link to clipboard
Copied
Hi! I just found a thread regarding hiding/showing all the layers in open documents, however the code's not doing anything when I try to run it.
var openDocuments = app.documents.everyItem().getElements();
for( var n=0; n<openDocuments.length; n++ )
{
var currentDoc = openDocuments[n] ;
var currentLayers = currentDoc.layers.everyItem().getElements();
for ( var j =0; j <currentLayers.length ; j++)
{
var currentLayer = currentLayers[j];
if ( /Guides|Dieline/.test ( currentLayer.name ) )
{
currentLayer.visible = false;
};
};
} ;
I'm also trying to make it to work only in a current document. Does anyone how to fix the lines above?
The script will make only those layers hidden which has Guides or Dieline in the layer name. If you want to hide all the layers then comment/remove out the following line
if ( /Guides|Dieline/.test ( currentLayer.name ) )
-Manan
Copy link to clipboard
Copied
The script will make only those layers hidden which has Guides or Dieline in the layer name. If you want to hide all the layers then comment/remove out the following line
if ( /Guides|Dieline/.test ( currentLayer.name ) )
-Manan
Copy link to clipboard
Copied
It worked. Thank you!
Copy link to clipboard
Copied
If you just want to work only on the current document then you can use the following one-liner as well
app.documents[0].layers.everyItem().visible = false
For all open documents, you can use the following code as well
app.documents.everyItem().layers.everyItem().visible = false
-Manan