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

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

251

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

Community Expert , 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

Votes

Translate

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

Votes

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!

Votes

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
Community Expert ,
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

Votes

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