14 Replies Latest reply on Jun 27, 2016 11:32 AM by Silly-V

    Script to pull pantone colors from a dataset and recolor selected areas

    jhurstML

      I am looking for a script that will pull information from a dataset and apply those colors to the necessary paths/compound paths. I am just starting to try an work with scripting so my knowledge level is low. Is there a way to have a path with a pre determined attribute note (ex. a) selected then to select same fill color and change those selected objects to the colors assigned to "a" in the dataset and do the same thing with a secondary color as well? As seen in the image, the blue block in the center would be "a" and the yellow would be "b" , then select same color fill would be executed from those two base points.

      Screen Shot 2016-06-21 at 11.16.11 AM.png

        • 1. Re: Script to pull pantone colors from a dataset and recolor selected areas
          Silly-V Adobe Community Professional

          You are super-welcome to try my very convoluted and user-unfriendly method! The pros? It's readily available! Cons: complicated setup!

          Interestingly you describe the exact scenario where this would be used.

           

          Illustrator Variable Data Advanced Techniques: Recoloring art from data column. | Vasily Hall | LinkedIn

          • 2. Re: Script to pull pantone colors from a dataset and recolor selected areas
            jhurstML Level 1

            Believe it or not, I actually have been trying to tweak yours already (unsuccessfully, I should add) to account for compound paths. Right now, as I am attempting to teach myself Java Script, my latest attempt at something that works is to label the blue block as "primary" in its notes and create an action that selects that object, and insert a menu command "select same fill color" and change it to "colorA" as is pre determined by the dataset then repeat the same process with the yellow block as "secondary" and "colorB" . In the script I will ( try to) initiate the actions with Application.doScript.  Silly-V  Is that something you think would work or should I quit while I am ahead?

            • 3. Re: Script to pull pantone colors from a dataset and recolor selected areas
              Silly-V Adobe Community Professional

              I think the new version I put up the other day does compound paths. Get the new one from the github.

              You should definitely learn more in scripting, it's a fun thing - until it takes over you life!

              But, you don't really need any actions with this - unless you're talking about calling this script from actions in the first place - as mostly intended for batch-processing.

               

              I see that you want to label the notes in your action, which is really not what this script is intended for - you ideally have your one dynamic document and your art items would need the notes applied only 1 time, manually, so that the batch processing will work for the rest of the items regarding the recoloring.

               

              If you have a single document and are using this technique to bring in a single dataset just for this purpose, it's really not the way to go - you may need to take a different approach and focus on something that's only custom to your workflow rather than trying to accommodate this particular technique.

               

              However if you are bringing in multiple datasets, it may be more useful and worth the time to set up the setup layer, etc.

              Still, to put your note label everywhere, you'd just manually select the same fill and write it into the attributes - no need to make an action to do this.

              • 4. Re: Script to pull pantone colors from a dataset and recolor selected areas
                jhurstML Level 1

                Thanks, I will give the newer version a try. I have multiple designs with templates setup like the screenshot I posted earlier, which is why i thought using select same fill color would be beneficial since some are have designs that are much more intricate. Each design template has to have the colors switched out a few hundred times to align with the colors of all of the different organizations I create apparel for. I have the sets for each organization setup already but wanted to make sure and account for as many design style options as possible. Without automation, my team and I go in manually and select a block, select same fill color, change it to the appropriate color then repeat for the secondary color and save out. If your updated script will accomplish this with all design possibilities, I truly appreciate it, if not... I still appreciate it. Working with your script has made me want to look further into what is possible with scripting. 

                • 5. Re: Script to pull pantone colors from a dataset and recolor selected areas
                  Silly-V Adobe Community Professional

                  Okay so if you do use spreadsheets and import the variables, you can take a good day or 2 and go over all your templates and manually selecting same fill and typing in the note, then save. With the note in there, it should be good for later use with the Recolor script. However, if you have many items in your document, it will be super-slow. Try it, though, hopefully it will work.

                  • 6. Re: Script to pull pantone colors from a dataset and recolor selected areas
                    jhurstML Level 1

                    A lot of the documents do contain a large amount of items, when I ran it, the compound paths changed color but it took around 5 mins for 1 data set. Is there any way you can think to speed it up?

                    • 7. Re: Script to pull pantone colors from a dataset and recolor selected areas
                      williamadowling Level 4

                      Man, lots of you guys in this community are doing THE EXACT SAME kind of work i do every day.. fascinating.

                       

                      Imagine how much easier this task would be if we had access to the stupid *******' MERGE SWATCHES method..

                       

                      are you listening adobe?!?!

                      • 8. Re: Script to pull pantone colors from a dataset and recolor selected areas
                        Silly-V Adobe Community Professional

                        Hmm, can you list your workflow on merging swatches? And, in this world, by workflow - I mean the detailed steps in the UI. We may have a chance to do a workaround!

                        • 9. Re: Script to pull pantone colors from a dataset and recolor selected areas
                          williamadowling Level 4

                          In the file, there exists each shirt piece of each size (much like @jhurstML showed in his/her screenshot).

                           

                          The templates/blank files are stored with placeholder (spot) colors. One placeholder color represents the main body of the shirt. One placeholder color represents side panels, and another for accent/trim colors etc.

                           

                          Scenario: I need to change all PHC1 colors to Royal Blue.

                           

                          In the Interface: Select "Royal Blue" in the swatches panel > cmd/ctrl select "PHC1" color in the swatches panel > click swatch menu item, "Merge Swatches". This removes PHC1 from the swatches panel, and applies Royal blue to any and all objects in the document (including any locked or hidden objects as well as live pattern fills).

                           

                          The problem in javascript: In order to change the color of an object with javascript, I must access the lowest level Path Item and update its fillColor property. As stated above, this goes very slowly in any document with a large number of pageItems since the script must find and evaluate every element.

                           

                          The obvious, but not good enough, solution: access the PHC1 swatch in the swatches panel, update the name to Royal Blue, and update the display color to match the royal blue swatch from the color library.

                           

                          The problem with this solution: If target color is already used elsewhere in the document (which it always will be since the mockup exists in the same document, so every color i need to change already exists), you cannot modify another swatch to have the same name as an existing swatch. RUNTIME ERROR: YOU LOSE, SUCKER! (i think that's what it says when you try).

                           

                          Thoughts?

                          • 10. Re: Script to pull pantone colors from a dataset and recolor selected areas
                            Silly-V Adobe Community Professional

                            What if you didn't have all your colors in the document and only had placeholder colors that you set up? I was looking at messing with swatch menu items, but it appears even if you did create a group, there isn't a way to only select the swatches within it, without having the 'folder group' icon also selected - this makes the Merge Swatches menu item unavailable.

                            • 11. Re: Script to pull pantone colors from a dataset and recolor selected areas
                              williamadowling Level 4

                              The mockup is already in the file (on it's own layer) for artwork placement purposes.. And the mockup already has the colors applied.. =(

                              • 12. Re: Script to pull pantone colors from a dataset and recolor selected areas
                                Silly-V Adobe Community Professional

                                How about when your script goes, you first change the mockup colors to the placeholder colors using an action or even select-same-fill, etc. And then your game is wide open for spot-color editing?

                                 

                                I will admit that I've created a script object to manage colors and change them quite well, but as it's used in a lot of client code which was funded, I really can't expose it here on the forum.

                                However, you can pretty easily come up with your own version: I used app.executeMenuCommand for selecting a same fill, and used defaultFill to set the fill color. (setting the color can also be done with a dynamic action too)

                                 

                                Actually I was looking to do explore the merge swatches action, but don't you end up with a whole bunch of swatches duplicated in the document then? The worst part is, you can't remove just the duplicates of swatches, because they all get removed!

                                • 13. Re: Script to pull pantone colors from a dataset and recolor selected areas
                                  williamadowling Level 4

                                  Thought about that too.. However the problem is that i'm rarely dealing with simple, solid fill colors. More often than not there are gradients or pattern fills or both. That's what makes "Merge Swatches" so attractive. It changes everything even if it's buried deep inside of an appearance or pattern fill.

                                  • 14. Re: Script to pull pantone colors from a dataset and recolor selected areas
                                    Silly-V Adobe Community Professional

                                    If there was only a way you could change the existing colors or somehow make it so that the existing colors were applied all across the board first, so that you could edit the swatch contents.