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.


Hide Layers

Explorer ,
May 01, 2021 May 01, 2021

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?

TOPICS
How to, Scripting

Views

127

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 , May 01, 2021 May 01, 2021
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

Likes

Translate

Translate
Adobe Community Professional ,
May 01, 2021 May 01, 2021

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

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
Explorer ,
May 01, 2021 May 01, 2021

Copy link to clipboard

Copied

It worked. Thank you!

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 ,
May 01, 2021 May 01, 2021

Copy link to clipboard

Copied

LATEST

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

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