Search code examples
javascriptadobe-illustrator

Illustrator script to find all colors in document


I am looking for a script that will give me a list of all the colors in an Adobe Illustrator document by there color numbers (rgb or cmyk). I have no code and have no idea how to do this, or if you even can. Can anyone please give me any information?


Solution

  • This will loop through all the shapes in the active document and gets posts an alert with their RGB fill colours:

    with (app.activeDocument) {
        if (pathItems.length > 0)
        {
            alert(pathItems.length);
            for (var g = 0 ; g < pathItems.length; g++)
              {
                   if (pathItems[g].filled == true)
                   {
                       if (pathItems[g].fillColor.red > 200 == true && pathItems[g].fillColor.red < 210 == true && pathItems[g].fillColor.green > 200 == true && pathItems[g].fillColor.green < 210 == true && pathItems[g].fillColor.blue > 200 == true && pathItems[g].fillColor.blue < 210 == true)
                           {
                            alert('R' + pathItems[g].fillColor.red + ' G' + pathItems[g].fillColor.green + ' B' + pathItems[g].fillColor.blue);
                            }
                   }
              }
          }
    } 
    

    Note: You document must be in RGB colour mode for this to work

    The long If line anwers your other question