2 Replies Latest reply on Aug 27, 2016 7:24 PM by Silly-V

    Is it possible to select a swatch or more by javascript?

    levi23 Level 1

      You see, I'm trying to create a script to select all swatch in document and does not work.

       

          var doc = app.activeDocument;    
          
          for (var j = 0; j < app.activeDocument.swatches.length; j++) {
              thisswatch= app.activeDocument.swatches[j];
              thisswatch.selected=true;               
          }  
      

       

       

      You know if it is possible?

       

       

      Simply that. Thank you very much in advance.

       

       

      A greeting.

        • 1. Re: Is it possible to select a swatch or more by javascript?
          o-marat Level 3

          levi2, hi!

          The object Swatch has no property "selected".

          What do you then want to do with the object?

           

          New

          You can get the object Swatch and then something to do with it: to use its properties, remove and place in a group. But Illustrator Swatches palette is not available from the script.

          • 2. Re: Is it possible to select a swatch or more by javascript?
            Silly-V Adobe Community Professional

            There is a super convoluted way to sort-of do this, which is to play an action which makes a new swatch group out of a selection (may need to draw some squares and fill them with color to produce the selection 1st.).

            Now, the swatches are selected in the swatches panel, and you can use the getSelected function of the 'swatches' object to do things with - but given its limited abilities, it's not going to be as great as just being able to make a swatch 'selected' in the panel as we would expect.