3

I am looking for a way, preferably one that can be triggered via keyboard shortcut, to both toggle the current layer to visible/hidden and to be able to toggle a specifically-named layer visible/hidden.

What I am aiming for with the specifically-named layer visibility toggle is to turn the template layer visible/hidden.

It would be great to be able to toggle without selecting the layer, but I'd take that option if that were all there was. Both would be ideal.

This Adobe forum post seemed to be the solution via scripting, until I realized it was for Photoshop, not Illustrator (handy nonetheless).

1 Answer 1

6

No problemo.

#target illustrator

layer = app.activeDocument.layers.getByName("Toggle")
layer.visible = ! layer.visible

Put this in a action and bind action to shortcut. NOTE: Adobe has no quality control for their scripting environment so the actions pallete will forget the script each time you start Illustrator so to get this working reload the default actions again and it works. Simply put actions palette is just initialized too early.

Update The load problem is now fixed after 10 years of waiting

4
  • How do you put a script in an action?
    – aaaidan
    Aug 19, 2014 at 2:34
  • Superb! Thank you. How would I go about editing this script to toggle the visibility of the currently selected layer?
    – George C
    Sep 12, 2014 at 21:27
  • I marked this as solved prematurely; the script itself works perfectly, but I am unable to get this script to record within an Action. In the past I've been able to do this with other scripts, but as you mentioned the action was losing the connection to the script upon startup.
    – George C
    Sep 12, 2014 at 21:35
  • 1
    yes its a longstanding bug in illustrator. its not actualy possible it worked before. but if you reload the scripts then illustrator finds them again. the init order is wrong and can not be fixed. This applies to all scripts and can not be scripted around. Yeah i know how to hack this, its not possible to share legaly tough, but really complain to adobe.
    – joojaa
    Sep 13, 2014 at 4:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.