6 Replies Latest reply on Feb 4, 2016 4:09 PM by Qwertyfly...

    Script/Plugin for automatic collour theme changing

    timmykgb Level 1

      Hi,

       

      I am looking for a plug-in where we can use the color themes in Illustrator CC in an automatic colour change function.

       

      So each of our colour themes has 5 colours.

       

      We want to be able to select objects on the design and 'tag' them to correspond to the colours in the themes.

       

      So for example...

       

      Tag '1' will always be color 1 in the theme

      Tag '2' will always be color 2 in the theme

      Tag '3' will always be color 3 in the theme

      Tag '4' will always be color 4 in the theme

      Tag '5' will always be color 5 in the theme

       

      And then whenever a theme is selected in the theme panel the colours change automatically to the selected theme based on the rules above.

       

      Is this possible? Maybe something similar is out there already?

       

      Thanks, Tim

        • 1. Re: Script/Plugin for automatic collour theme changing
          Qwertyfly... Level 4

          this should give you a good place to start.

          you can Tag each item in the Attributes Panel.

          see below.

          note.JPG

           

          the c8 refers to the 8th swatch in the swatch panel.

          here's the script that will change the fill color of all pathItems that have a c* tag in the notes.

           

          var doc = app.activeDocument;
          var items = doc.pathItems;
          for(var i = 0; i < items.length; i++){
              var item = items[i];
              if(item.note){
                  if(item.note.substring(0,1) == "c"){
                      var num = item.note.substring(1);
                      item.fillColor = doc.swatches[num-1].color;
                  }
              }
          }
          
          • 2. Re: Script/Plugin for automatic collour theme changing
            timmykgb Level 1

            Hey, thanks for the reply.

             

            Excuse my ignorance here.

             

            So what I did was create 5 boxes and color them from the 'color theme' panel (I created the color themes in my adobe account and it syncs with CC). I tagged each one c1, c2, c3, c4 and c5 in the attributes panel. I put the script into the extendscript toolkit and saved a .jsx.

             

            When I run that script from Illustrator it changes the colors to the first color group in the swatch. Which includes 'none', 'registration', 'white' etc, but it does not change to any other groups/themes if I select them.

             

            Also, our requirement has changed to commission a script for a batch process if anyone would like to take it on.

             

            So the procedure is...

             

            1. We have 75 color groups/themes which sync into the 'color themes' panel on our desktop illustrator. Each of these groups have 5 colors.

            2. We have a source folder with 100s of illustrator files that use the colors from one of these color groups/themes in various objects and text elements on the design.

            3. The script picks up these files and creates 75 versions (one for each color theme/group) as .ai and .pdf

             

            So whatever way we need to tag or prepare the files we can do, and just need a script to carry out the task then.

             

            Thanks, Tim

            • 3. Re: Script/Plugin for automatic collour theme changing
              CarlosCanto Adobe Community Professional & MVP

              javascript doesn't have access to Cloud Theme Colors, you need to add them to the current document's swatch panel first, to do so, on your Color Themes Panel, click on the folder icon to the left of the color chips, this should create a swatch group with the name of your Color Theme.

               

              run this version of quertyfly's script, the script should use the colors of the swatch group "My Color Theme"

               

              var doc = app.activeDocument; 
              var items = doc.pathItems; 
              for(var i = 0; i < items.length; i++){ 
                  var item = items[i]; 
                  var colorgroup = doc.swatchGroups['My Color Theme'];
                  var swatches = colorgroup.getAllSwatches();
                  if(item.note){ 
                      if(item.note.substring(0,1) == "c"){ 
                          var num = item.note.substring(1); 
                          item.fillColor = swatches[num-1].color; 
                      } 
                  } 
              }
              
              • 4. Re: Script/Plugin for automatic collour theme changing
                Qwertyfly... Level 4

                As carlos stated we don't have access the cloud color themes from JS.

                but if all 75 themes are saved to 1 document and saved it is possible to use that as a source for the themes.

                 

                batching the large qty of files is not a problem

                saving out 75 versions is also not a big project

                 

                going through the 100's of files and tagging them all could be a big task.

                do you plan to do that manually or do you want that done with a script?

                • 5. Re: Script/Plugin for automatic collour theme changing
                  timmykgb Level 1

                  Hi thanks for the replies.

                   

                  I think the best procedure would be for

                   

                  1. Put all our colour palettes into the swatch list of a 'master' file. MANUAL STEP

                  2. Create our 100s of files with the coloured artwork (each file uses one palette, colours 1 to 5) MANUAL STEP... example of palettes in screenshot

                  3. Run script on these files to automatically change the colours to the other palettes in the swatch panel, and output a version of each one as .ai and ,jpg SCRIPT STEP

                   

                  So the way I see it, do we need to even tag elements. There will be elements using colours as well as text. Can the script go, ok this element fill or border, or this text uses colour 1 in the palette, so then it changes to colour 1 in all the other palette versions? Some of these elements and text will be grouped in illustrator, using different colours in the palette, is that ok for the script to change colours etc?

                   

                  Thanks very much, Tim

                   

                  There will probably be a step afterwards where a script takes the grouped items off these files and creates single files for each grouped item.

                   

                  Screen Shot 2016-02-04 at 14.17.41.png

                  • 6. Re: Script/Plugin for automatic collour theme changing
                    Qwertyfly... Level 4

                    are these themes going to change?

                    or added to?

                    is this a one off process?

                    or will this need to be done many times?

                     

                    your color themes will be saved in a library.

                    if you share a link to your library of color themes I can extract the color info.

                    having the swatch info as a table of values will greatly reduce the complexity of the script.

                    will also eliminate the need for the master color file.

                     

                    but then if this is going to be a ongoing process with new color themes being added etc., then above would just be annoying to have to do every time.

                     

                    you wont need to add a tag in the notes of every page item.

                    as long as you use the same 5 colors for each of the 100+ files.

                    would help if these 5 colors are the only colors in the doc.

                    would also be a big BIG help if these 5 colors are set to be global.

                     

                    we can essentially do something like this, (just a snippet and not tested or even run, this is just for gist...

                    for(var f = 0; f < filesToProcess.length; f++){
                        for(var g = 0; g < colorThemes.length; g++){
                            var docSwatchGroup = doc.swatchGroups.getByName("DefaultTheme");
                            var docSwatches = docSwatchGroup.getAllSwatches();
                            for(h = 0; h < 4; h++){
                                var sw = docSwatches[h].color.spot.color;
                                sw.cyan = Theme[g].Swatch[h].C;
                                sw.magenta = Theme[g].Swatch[h].M;
                                sw.yellow = Theme[g].Swatch[h].Y;
                                sw.black = Theme[g].Swatch[h].B;
                            }
                        }
                    }