Recolor Artwork: single swatch to multiple swatches

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I have an Illustrator document with a lot of objects. All the objects are black, same swatch.



I have a swatch group with a few dozen coloured swatches. I wish to apply these swatches to all the many black objects. It doesn’t have to be in any particular order, but each object should be coloured individually—I don’t just want to change black into some other colour, but to dozens of other colours. What I really want to avoid is having to select each object individually and then applying a different swatch to each.



I’ve never quite managed to get my head properly around the Recolor Artwork feature in Illustrator, and I cannot for the life of me get it to do anything like this. The “New” box in the Recolor Artwork dialogue box appears to accept only one colour.



Is there some way to do this using the Recolor Artwork feature? Or using some other feature that I’m not aware of? Bonus points if there’s a way to control the order in which the colours are applied; e.g., specifying an order and then click on each object in turn to apply each swatch being ‘iterated’ through in that order.



(I would prefer to avoid having to script it, but I will if there’s no other way.)







share|improve this question























    up vote
    2
    down vote

    favorite












    I have an Illustrator document with a lot of objects. All the objects are black, same swatch.



    I have a swatch group with a few dozen coloured swatches. I wish to apply these swatches to all the many black objects. It doesn’t have to be in any particular order, but each object should be coloured individually—I don’t just want to change black into some other colour, but to dozens of other colours. What I really want to avoid is having to select each object individually and then applying a different swatch to each.



    I’ve never quite managed to get my head properly around the Recolor Artwork feature in Illustrator, and I cannot for the life of me get it to do anything like this. The “New” box in the Recolor Artwork dialogue box appears to accept only one colour.



    Is there some way to do this using the Recolor Artwork feature? Or using some other feature that I’m not aware of? Bonus points if there’s a way to control the order in which the colours are applied; e.g., specifying an order and then click on each object in turn to apply each swatch being ‘iterated’ through in that order.



    (I would prefer to avoid having to script it, but I will if there’s no other way.)







    share|improve this question





















      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I have an Illustrator document with a lot of objects. All the objects are black, same swatch.



      I have a swatch group with a few dozen coloured swatches. I wish to apply these swatches to all the many black objects. It doesn’t have to be in any particular order, but each object should be coloured individually—I don’t just want to change black into some other colour, but to dozens of other colours. What I really want to avoid is having to select each object individually and then applying a different swatch to each.



      I’ve never quite managed to get my head properly around the Recolor Artwork feature in Illustrator, and I cannot for the life of me get it to do anything like this. The “New” box in the Recolor Artwork dialogue box appears to accept only one colour.



      Is there some way to do this using the Recolor Artwork feature? Or using some other feature that I’m not aware of? Bonus points if there’s a way to control the order in which the colours are applied; e.g., specifying an order and then click on each object in turn to apply each swatch being ‘iterated’ through in that order.



      (I would prefer to avoid having to script it, but I will if there’s no other way.)







      share|improve this question











      I have an Illustrator document with a lot of objects. All the objects are black, same swatch.



      I have a swatch group with a few dozen coloured swatches. I wish to apply these swatches to all the many black objects. It doesn’t have to be in any particular order, but each object should be coloured individually—I don’t just want to change black into some other colour, but to dozens of other colours. What I really want to avoid is having to select each object individually and then applying a different swatch to each.



      I’ve never quite managed to get my head properly around the Recolor Artwork feature in Illustrator, and I cannot for the life of me get it to do anything like this. The “New” box in the Recolor Artwork dialogue box appears to accept only one colour.



      Is there some way to do this using the Recolor Artwork feature? Or using some other feature that I’m not aware of? Bonus points if there’s a way to control the order in which the colours are applied; e.g., specifying an order and then click on each object in turn to apply each swatch being ‘iterated’ through in that order.



      (I would prefer to avoid having to script it, but I will if there’s no other way.)









      share|improve this question










      share|improve this question




      share|improve this question









      asked Aug 6 at 19:17









      Janus Bahs Jacquet

      1,6411019




      1,6411019




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote













          This script RandomSwatchesFill.jsx does exactly that, selecting all the shapes and all the swatches:



          script



          mySelection = app.activeDocument.selection;
          myDoc = app.activeDocument;
          if (mySelection instanceof Array)

          selSwatches = myDoc.swatches.getSelected();

          if(selSwatches.length != 0)
          for (i=0; i<mySelection.length; i++)
          mySelection[i].typename == "CompoundPathItem")

          selItem = mySelection[i];
          selItem.filled = true;

          swatchIndex = Math.round( Math.random() * (selSwatches.length - 1 ));

          if(selItem.typename == "PathItem")
          selItem.fillColor = selSwatches[swatchIndex].color;
          else
          selItem.pathItems[0].fillColor = selSwatches[swatchIndex].color;






          If you download it change the extension from .js to .jsx






          share|improve this answer























          • Thank you for that! Accepting that there is probably no GUI-based way to do this easily, I adapted this script to use a user-defined swatch group (instead of selected swatches) and iterate through them in order (instead of choosing one at random). Works perfectly well!
            – Janus Bahs Jacquet
            Aug 7 at 17:10










          • @JanusBahsJacquet a script can have a gui
            – joojaa
            Aug 7 at 18:00










          • @joojaa I meant the built-in Illustrator GUI-driven functions available through menus and panels, obviously.
            – Janus Bahs Jacquet
            Aug 7 at 18:02










          • @JanusBahsJacquet you can make the script appear in a menu. You cant expect illustrator to do much things since it has no concept of parametric design.
            – joojaa
            Aug 7 at 19:12

















          up vote
          0
          down vote



          accepted










          The script posted/linked to by Danielillo does most of what I was looking for. I used it as the basis for the following script, which asks the user for the name of the swatch group to use, and then iterates through the selected objects and the swatches in the named swatch group, applying the current colour to the current object.



          (The objects I had needed to have their stroke, rather than their fill, changed, so I also changed that. To colour the fill instead of the stroke, replace strokeColor with fillColor.)



          var selected = app.activeDocument.selection;
          var doc = app.activeDocument;
          var swatchIndex = 0;

          if (selected instanceof Array)
          title = prompt("Please enter the name of the swatch group containing the colours to apply.", "");

          if (title)
          swatches = doc.swatchGroups.getByName(title).getAllSwatches();

          if (swatches.length != 0)
          for (i = 0, j = selected.length; i < j; i++)
          item = selected[i];
          if (swatchIndex >= swatches.length) swatchIndex = 0;

          if (item.typename == "CompoundPathItem")
          item = item.pathItems[0];


          if (item.typename == "PathItem")
          item.strokeColor = swatches[swatchIndex].color;
          swatchIndex++;







          (The script does not handle exceptions, so if you type in an incorrect swatch group name, you’ll probably just get errors thrown at you.)






          share|improve this answer























          • Note, your adaptation also switched it to stroke color, not fill color.
            – WELZ
            Aug 7 at 18:54










          • @WELZ Forgot to mention that, thanks—edited!
            – Janus Bahs Jacquet
            Aug 7 at 18:55










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "174"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgraphicdesign.stackexchange.com%2fquestions%2f113526%2frecolor-artwork-single-swatch-to-multiple-swatches%23new-answer', 'question_page');

          );

          Post as a guest






























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote













          This script RandomSwatchesFill.jsx does exactly that, selecting all the shapes and all the swatches:



          script



          mySelection = app.activeDocument.selection;
          myDoc = app.activeDocument;
          if (mySelection instanceof Array)

          selSwatches = myDoc.swatches.getSelected();

          if(selSwatches.length != 0)
          for (i=0; i<mySelection.length; i++)
          mySelection[i].typename == "CompoundPathItem")

          selItem = mySelection[i];
          selItem.filled = true;

          swatchIndex = Math.round( Math.random() * (selSwatches.length - 1 ));

          if(selItem.typename == "PathItem")
          selItem.fillColor = selSwatches[swatchIndex].color;
          else
          selItem.pathItems[0].fillColor = selSwatches[swatchIndex].color;






          If you download it change the extension from .js to .jsx






          share|improve this answer























          • Thank you for that! Accepting that there is probably no GUI-based way to do this easily, I adapted this script to use a user-defined swatch group (instead of selected swatches) and iterate through them in order (instead of choosing one at random). Works perfectly well!
            – Janus Bahs Jacquet
            Aug 7 at 17:10










          • @JanusBahsJacquet a script can have a gui
            – joojaa
            Aug 7 at 18:00










          • @joojaa I meant the built-in Illustrator GUI-driven functions available through menus and panels, obviously.
            – Janus Bahs Jacquet
            Aug 7 at 18:02










          • @JanusBahsJacquet you can make the script appear in a menu. You cant expect illustrator to do much things since it has no concept of parametric design.
            – joojaa
            Aug 7 at 19:12














          up vote
          3
          down vote













          This script RandomSwatchesFill.jsx does exactly that, selecting all the shapes and all the swatches:



          script



          mySelection = app.activeDocument.selection;
          myDoc = app.activeDocument;
          if (mySelection instanceof Array)

          selSwatches = myDoc.swatches.getSelected();

          if(selSwatches.length != 0)
          for (i=0; i<mySelection.length; i++)
          mySelection[i].typename == "CompoundPathItem")

          selItem = mySelection[i];
          selItem.filled = true;

          swatchIndex = Math.round( Math.random() * (selSwatches.length - 1 ));

          if(selItem.typename == "PathItem")
          selItem.fillColor = selSwatches[swatchIndex].color;
          else
          selItem.pathItems[0].fillColor = selSwatches[swatchIndex].color;






          If you download it change the extension from .js to .jsx






          share|improve this answer























          • Thank you for that! Accepting that there is probably no GUI-based way to do this easily, I adapted this script to use a user-defined swatch group (instead of selected swatches) and iterate through them in order (instead of choosing one at random). Works perfectly well!
            – Janus Bahs Jacquet
            Aug 7 at 17:10










          • @JanusBahsJacquet a script can have a gui
            – joojaa
            Aug 7 at 18:00










          • @joojaa I meant the built-in Illustrator GUI-driven functions available through menus and panels, obviously.
            – Janus Bahs Jacquet
            Aug 7 at 18:02










          • @JanusBahsJacquet you can make the script appear in a menu. You cant expect illustrator to do much things since it has no concept of parametric design.
            – joojaa
            Aug 7 at 19:12












          up vote
          3
          down vote










          up vote
          3
          down vote









          This script RandomSwatchesFill.jsx does exactly that, selecting all the shapes and all the swatches:



          script



          mySelection = app.activeDocument.selection;
          myDoc = app.activeDocument;
          if (mySelection instanceof Array)

          selSwatches = myDoc.swatches.getSelected();

          if(selSwatches.length != 0)
          for (i=0; i<mySelection.length; i++)
          mySelection[i].typename == "CompoundPathItem")

          selItem = mySelection[i];
          selItem.filled = true;

          swatchIndex = Math.round( Math.random() * (selSwatches.length - 1 ));

          if(selItem.typename == "PathItem")
          selItem.fillColor = selSwatches[swatchIndex].color;
          else
          selItem.pathItems[0].fillColor = selSwatches[swatchIndex].color;






          If you download it change the extension from .js to .jsx






          share|improve this answer















          This script RandomSwatchesFill.jsx does exactly that, selecting all the shapes and all the swatches:



          script



          mySelection = app.activeDocument.selection;
          myDoc = app.activeDocument;
          if (mySelection instanceof Array)

          selSwatches = myDoc.swatches.getSelected();

          if(selSwatches.length != 0)
          for (i=0; i<mySelection.length; i++)
          mySelection[i].typename == "CompoundPathItem")

          selItem = mySelection[i];
          selItem.filled = true;

          swatchIndex = Math.round( Math.random() * (selSwatches.length - 1 ));

          if(selItem.typename == "PathItem")
          selItem.fillColor = selSwatches[swatchIndex].color;
          else
          selItem.pathItems[0].fillColor = selSwatches[swatchIndex].color;






          If you download it change the extension from .js to .jsx







          share|improve this answer















          share|improve this answer



          share|improve this answer








          edited Aug 6 at 21:22


























          answered Aug 6 at 20:49









          Danielillo

          10.1k11345




          10.1k11345











          • Thank you for that! Accepting that there is probably no GUI-based way to do this easily, I adapted this script to use a user-defined swatch group (instead of selected swatches) and iterate through them in order (instead of choosing one at random). Works perfectly well!
            – Janus Bahs Jacquet
            Aug 7 at 17:10










          • @JanusBahsJacquet a script can have a gui
            – joojaa
            Aug 7 at 18:00










          • @joojaa I meant the built-in Illustrator GUI-driven functions available through menus and panels, obviously.
            – Janus Bahs Jacquet
            Aug 7 at 18:02










          • @JanusBahsJacquet you can make the script appear in a menu. You cant expect illustrator to do much things since it has no concept of parametric design.
            – joojaa
            Aug 7 at 19:12
















          • Thank you for that! Accepting that there is probably no GUI-based way to do this easily, I adapted this script to use a user-defined swatch group (instead of selected swatches) and iterate through them in order (instead of choosing one at random). Works perfectly well!
            – Janus Bahs Jacquet
            Aug 7 at 17:10










          • @JanusBahsJacquet a script can have a gui
            – joojaa
            Aug 7 at 18:00










          • @joojaa I meant the built-in Illustrator GUI-driven functions available through menus and panels, obviously.
            – Janus Bahs Jacquet
            Aug 7 at 18:02










          • @JanusBahsJacquet you can make the script appear in a menu. You cant expect illustrator to do much things since it has no concept of parametric design.
            – joojaa
            Aug 7 at 19:12















          Thank you for that! Accepting that there is probably no GUI-based way to do this easily, I adapted this script to use a user-defined swatch group (instead of selected swatches) and iterate through them in order (instead of choosing one at random). Works perfectly well!
          – Janus Bahs Jacquet
          Aug 7 at 17:10




          Thank you for that! Accepting that there is probably no GUI-based way to do this easily, I adapted this script to use a user-defined swatch group (instead of selected swatches) and iterate through them in order (instead of choosing one at random). Works perfectly well!
          – Janus Bahs Jacquet
          Aug 7 at 17:10












          @JanusBahsJacquet a script can have a gui
          – joojaa
          Aug 7 at 18:00




          @JanusBahsJacquet a script can have a gui
          – joojaa
          Aug 7 at 18:00












          @joojaa I meant the built-in Illustrator GUI-driven functions available through menus and panels, obviously.
          – Janus Bahs Jacquet
          Aug 7 at 18:02




          @joojaa I meant the built-in Illustrator GUI-driven functions available through menus and panels, obviously.
          – Janus Bahs Jacquet
          Aug 7 at 18:02












          @JanusBahsJacquet you can make the script appear in a menu. You cant expect illustrator to do much things since it has no concept of parametric design.
          – joojaa
          Aug 7 at 19:12




          @JanusBahsJacquet you can make the script appear in a menu. You cant expect illustrator to do much things since it has no concept of parametric design.
          – joojaa
          Aug 7 at 19:12










          up vote
          0
          down vote



          accepted










          The script posted/linked to by Danielillo does most of what I was looking for. I used it as the basis for the following script, which asks the user for the name of the swatch group to use, and then iterates through the selected objects and the swatches in the named swatch group, applying the current colour to the current object.



          (The objects I had needed to have their stroke, rather than their fill, changed, so I also changed that. To colour the fill instead of the stroke, replace strokeColor with fillColor.)



          var selected = app.activeDocument.selection;
          var doc = app.activeDocument;
          var swatchIndex = 0;

          if (selected instanceof Array)
          title = prompt("Please enter the name of the swatch group containing the colours to apply.", "");

          if (title)
          swatches = doc.swatchGroups.getByName(title).getAllSwatches();

          if (swatches.length != 0)
          for (i = 0, j = selected.length; i < j; i++)
          item = selected[i];
          if (swatchIndex >= swatches.length) swatchIndex = 0;

          if (item.typename == "CompoundPathItem")
          item = item.pathItems[0];


          if (item.typename == "PathItem")
          item.strokeColor = swatches[swatchIndex].color;
          swatchIndex++;







          (The script does not handle exceptions, so if you type in an incorrect swatch group name, you’ll probably just get errors thrown at you.)






          share|improve this answer























          • Note, your adaptation also switched it to stroke color, not fill color.
            – WELZ
            Aug 7 at 18:54










          • @WELZ Forgot to mention that, thanks—edited!
            – Janus Bahs Jacquet
            Aug 7 at 18:55














          up vote
          0
          down vote



          accepted










          The script posted/linked to by Danielillo does most of what I was looking for. I used it as the basis for the following script, which asks the user for the name of the swatch group to use, and then iterates through the selected objects and the swatches in the named swatch group, applying the current colour to the current object.



          (The objects I had needed to have their stroke, rather than their fill, changed, so I also changed that. To colour the fill instead of the stroke, replace strokeColor with fillColor.)



          var selected = app.activeDocument.selection;
          var doc = app.activeDocument;
          var swatchIndex = 0;

          if (selected instanceof Array)
          title = prompt("Please enter the name of the swatch group containing the colours to apply.", "");

          if (title)
          swatches = doc.swatchGroups.getByName(title).getAllSwatches();

          if (swatches.length != 0)
          for (i = 0, j = selected.length; i < j; i++)
          item = selected[i];
          if (swatchIndex >= swatches.length) swatchIndex = 0;

          if (item.typename == "CompoundPathItem")
          item = item.pathItems[0];


          if (item.typename == "PathItem")
          item.strokeColor = swatches[swatchIndex].color;
          swatchIndex++;







          (The script does not handle exceptions, so if you type in an incorrect swatch group name, you’ll probably just get errors thrown at you.)






          share|improve this answer























          • Note, your adaptation also switched it to stroke color, not fill color.
            – WELZ
            Aug 7 at 18:54










          • @WELZ Forgot to mention that, thanks—edited!
            – Janus Bahs Jacquet
            Aug 7 at 18:55












          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          The script posted/linked to by Danielillo does most of what I was looking for. I used it as the basis for the following script, which asks the user for the name of the swatch group to use, and then iterates through the selected objects and the swatches in the named swatch group, applying the current colour to the current object.



          (The objects I had needed to have their stroke, rather than their fill, changed, so I also changed that. To colour the fill instead of the stroke, replace strokeColor with fillColor.)



          var selected = app.activeDocument.selection;
          var doc = app.activeDocument;
          var swatchIndex = 0;

          if (selected instanceof Array)
          title = prompt("Please enter the name of the swatch group containing the colours to apply.", "");

          if (title)
          swatches = doc.swatchGroups.getByName(title).getAllSwatches();

          if (swatches.length != 0)
          for (i = 0, j = selected.length; i < j; i++)
          item = selected[i];
          if (swatchIndex >= swatches.length) swatchIndex = 0;

          if (item.typename == "CompoundPathItem")
          item = item.pathItems[0];


          if (item.typename == "PathItem")
          item.strokeColor = swatches[swatchIndex].color;
          swatchIndex++;







          (The script does not handle exceptions, so if you type in an incorrect swatch group name, you’ll probably just get errors thrown at you.)






          share|improve this answer















          The script posted/linked to by Danielillo does most of what I was looking for. I used it as the basis for the following script, which asks the user for the name of the swatch group to use, and then iterates through the selected objects and the swatches in the named swatch group, applying the current colour to the current object.



          (The objects I had needed to have their stroke, rather than their fill, changed, so I also changed that. To colour the fill instead of the stroke, replace strokeColor with fillColor.)



          var selected = app.activeDocument.selection;
          var doc = app.activeDocument;
          var swatchIndex = 0;

          if (selected instanceof Array)
          title = prompt("Please enter the name of the swatch group containing the colours to apply.", "");

          if (title)
          swatches = doc.swatchGroups.getByName(title).getAllSwatches();

          if (swatches.length != 0)
          for (i = 0, j = selected.length; i < j; i++)
          item = selected[i];
          if (swatchIndex >= swatches.length) swatchIndex = 0;

          if (item.typename == "CompoundPathItem")
          item = item.pathItems[0];


          if (item.typename == "PathItem")
          item.strokeColor = swatches[swatchIndex].color;
          swatchIndex++;







          (The script does not handle exceptions, so if you type in an incorrect swatch group name, you’ll probably just get errors thrown at you.)







          share|improve this answer















          share|improve this answer



          share|improve this answer








          edited Aug 7 at 18:55


























          answered Aug 7 at 17:23









          Janus Bahs Jacquet

          1,6411019




          1,6411019











          • Note, your adaptation also switched it to stroke color, not fill color.
            – WELZ
            Aug 7 at 18:54










          • @WELZ Forgot to mention that, thanks—edited!
            – Janus Bahs Jacquet
            Aug 7 at 18:55
















          • Note, your adaptation also switched it to stroke color, not fill color.
            – WELZ
            Aug 7 at 18:54










          • @WELZ Forgot to mention that, thanks—edited!
            – Janus Bahs Jacquet
            Aug 7 at 18:55















          Note, your adaptation also switched it to stroke color, not fill color.
          – WELZ
          Aug 7 at 18:54




          Note, your adaptation also switched it to stroke color, not fill color.
          – WELZ
          Aug 7 at 18:54












          @WELZ Forgot to mention that, thanks—edited!
          – Janus Bahs Jacquet
          Aug 7 at 18:55




          @WELZ Forgot to mention that, thanks—edited!
          – Janus Bahs Jacquet
          Aug 7 at 18:55












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgraphicdesign.stackexchange.com%2fquestions%2f113526%2frecolor-artwork-single-swatch-to-multiple-swatches%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Greedy Best First Search implementation in Rust

          Function to Return a JSON Like Objects Using VBA Collections and Arrays

          C++11 CLH Lock Implementation