Jump to content

 
Photo

Delete hidden layers - Illustrator

- - - - -

  • Please log in to reply
5 replies to this topic

#1
Mike Boruta

Mike Boruta

    Key Contributor

  • Validated Member
  • PipPipPip
  • 99 posts
  • Gender:Male
  • Location:Ouray, Colorado
  • United States

Does anyone know of a script or an easy method of deleting hidden layers in Illy? I have several files with extra data layers that were used to help make the maps, but I no longer need these layers. Rather then deleting them one-by-one I'm wondering if I could just automatically delete all the layers that are not visible.

#2
Brian Moran

Brian Moran

    Contributor

  • Validated Member
  • PipPip
  • 32 posts
  • Gender:Male
  • Location:Bay Area, California
  • United States

Does anyone know of a script or an easy method of deleting hidden layers in Illy? I have several files with extra data layers that were used to help make the maps, but I no longer need these layers. Rather then deleting them one-by-one I'm wondering if I could just automatically delete all the layers that are not visible.



The following js code should delete all layers in a doc that are not visible. If you have sublayers you want to deal with too, you'd have to add another loop in there to look through sublayers of each layer...

#target illustrator
var myDoc=app.activeDocument;
var layerCount=myDoc.layers.length;
for (var ii = layerCount - 1; ii >= 0; ii--) {
var currentLayer = myDoc.layers[ii];
currentLayer.locked = false;
if (currentLayer.visible == false){
currentLayer.visible = true;
currentLayer.remove();
}
}


edit to add: for some reason the indents didn't show up in my post...

#3
Mike Boruta

Mike Boruta

    Key Contributor

  • Validated Member
  • PipPipPip
  • 99 posts
  • Gender:Male
  • Location:Ouray, Colorado
  • United States

Thanks Brian. Although I really don't know much about coding. The only scripts I've used in Illy are ones that other people have made and I've added to the Scripts folder. Forgive my ignorance, but how would I save this in a way to use with Illy (preferably in a way that would also look through a documents sublayers)?

#4
Brian Moran

Brian Moran

    Contributor

  • Validated Member
  • PipPip
  • 32 posts
  • Gender:Male
  • Location:Bay Area, California
  • United States

Mike-
attached is the above code saved as a jsx script... just use it as other scripts you've used in AI. Hope it works for you.

Attached Files



#5
Mike Boruta

Mike Boruta

    Key Contributor

  • Validated Member
  • PipPipPip
  • 99 posts
  • Gender:Male
  • Location:Ouray, Colorado
  • United States

That works great. How hard would it be to modify the script so that it also deletes hidden sublayers?

#6
Brian Moran

Brian Moran

    Contributor

  • Validated Member
  • PipPip
  • 32 posts
  • Gender:Male
  • Location:Bay Area, California
  • United States

That works great. How hard would it be to modify the script so that it also deletes hidden sublayers?


Hi-
Sorry, I don't often check in here. I modified that script to delete hidden sub-layers too. Hope it works for you.

Attached Files






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

-->