14 Replies Latest reply on Jan 14, 2018 9:01 AM by m5heath

    Layer color

    m5heath Level 1

      I like to have all my Illustrator layers set to the same color - medium blue.

       

      Is there a quick or automated way of doing that instead of the slightly wearisome method of setting each one individually?

        • 1. Re: Layer color
          michelew83603738 Adobe Community Professional

          You could probably write an action and run it at the beginning of every file. You might want to ask on the Illustrator ActionScripting Forum.

          • 2. Re: Layer color
            pixxxel schubser MVP & Adobe Community Professional

            Hi m5heath,

            I also afraid you need a script for your requirement. (An action can't do this for different number of layers.) But you have no acces to the 'layer color short names'. You have to define the color based of the rgb values instead.

             

            Do you have scripting skills or do you know how to use scripts?

            Perhaps a moderator can move this thread to Illustrator Scripting

             

            For the beginning: here is a sample [JS] code for changing the layer color of active layer (without error management)

            var aDoc = app.activeDocument;
            var aLay, mediumBlueCol;
            try {
                aLay = aDoc.activeLayer;
                mediumBlueCol = new RGBColor();
                mediumBlueCol.red = 79;
                mediumBlueCol.green = 79;
                mediumBlueCol.blue = 255;
                aLay.color = mediumBlueCol;
            } catch (e) {};
            

             

            Have fun

             

            1 person found this helpful
            • 3. Re: Layer color
              theangietaylor Adobe Community Professional

              If you select one item, then Double-click the Color swatch and Check the Box to make it a global Color. Now when you change the Color for one of the items, all the others will also update.

               

              alternatively, if you don’t want to use global colours, select one item, then go to “Select Same Fill Color”. This will select all of the items. The. Change the Color.

              • 4. Re: Layer color
                m5heath Level 1

                I think you're talking about color of objects - I'm talking about layer color ie the color you set when you double-click on a layer and get the layer dialogue box

                • 5. Re: Layer color
                  m5heath Level 1

                  Thanks a million for this script which I've tested and it works perfectly for one layer and that's a big help. It doesn't work for more than one layer (selected with Shift-click) and I wonder if there is an easy tweak to extend the functionality of the script to do that. Also, is there a way to run a script using a keyboard shortcut?

                  Sadly I do not have scripting skills.

                  • 6. Re: Layer color
                    m5heath Level 1

                    I've tried creating an action but all it does is open the layer dialogue. I think

                    • 7. Re: Layer color
                      pixxxel schubser MVP & Adobe Community Professional

                      I also think that there is no other way.

                       

                      You're lucky.

                      After many many … many years is it since Illustrator 22 (CC2018) now finally possible to call a script with an action. You can give your action a shortcut. And that's it.

                       

                      But yes, the script snippet I've posted before only works with the active layer. The reason is a lack of informations.

                       

                      Some notes/questions:

                      Do you only want to change existing toplevel layers?

                      Or do you want this for new created layers or sublayers with and without objects?

                      or

                      Are there layers with sublayers with and without objects

                      Are there nested layers and/or nested sublayers with and without objects

                       

                      Are there hidden or locked layers or sublayers or objects? I believe you know that it's not possible to do anything with locked layers/sublayers. You have them at first to unlock for any changings and to lock them after again.

                      1 person found this helpful
                      • 8. Re: Layer color
                        m5heath Level 1

                        Thanks for your response. In a perfect world, it would be nice to be able to select all layers, sub-layers, with and without objects and do the color change once but if that is difficult, a script to do selected top level layers only would still be extremely helpful. I generally start a project by creating and naming 6 to 10 layers and to be able to flip those all to medium blue would be great. What a shame there isn't a preferences setting to do it.

                        • 9. Re: Layer color
                          DougKatz Level 2

                          In older versions, you could highlight all your layers, then double click on one of them to call the dialog for setting layer color. Once you selected your preferred color and dismissed the dialog, all layers would be set with that color. At least in 2017, this no longer works. What I do now is highlight all layers, select Options for selection… from the layers panel dropdown menu, and set the color in that dialog.

                           

                          Not optimal, but better than changing each layer's color individually.

                          1 person found this helpful
                          • 10. Re: Layer color
                            Kurt Gold Adobe Community Professional

                            You may also take a look at this topic:

                             

                            Layer colors - set default

                            2 people found this helpful
                            • 11. Re: Layer color
                              m5heath Level 1

                              Thanks so much - that works too. Life is looking up!

                              • 12. Re: Layer color
                                m5heath Level 1

                                Brilliant! Thanks so much for that - nice little action that does what it says on the tin!

                                • 13. Re: Layer color
                                  pixxxel schubser MVP & Adobe Community Professional

                                  New created layers are never locked.

                                  For all layers try this:

                                  var aDoc = app.activeDocument;
                                  var theLay = aDoc.layers;
                                  
                                  var mediumBlueCol = new RGBColor();
                                  mediumBlueCol.red = 79;
                                  mediumBlueCol.green = 79;
                                  mediumBlueCol.blue = 255;
                                  
                                  for (i=0; i<theLay.length; i++) {
                                      theLay[i].color = mediumBlueCol;
                                  }
                                  var shakeIllustrator = app.documents.add();
                                  shakeIllustrator.close (SaveOptions. DONOTSAVECHANGES);
                                  

                                   

                                  Have fun

                                   

                                  • 14. Re: Layer color
                                    m5heath Level 1

                                    Yesss! Works very well - you are a star. I'm so grateful.