2 Replies Latest reply on Sep 25, 2008 12:07 AM by bART2007

    FillColor of a Rectangle is Swatch("None")

    bART2007
      I received a InDesign document that contains a rectangle with a fill color that's not in the swatch list (when opening the document in the UI). The color was chosen directly in the color picker (R=53, G=53, B=45).
      When I get the fill color of the rectangle in my code, a swatch with name "None" is returned. This seems logical, but how can I find out what the fill color of the rectangle is, in other words how can I find the RGB values as specified in the color picker?

      Thanks in advance.

      Chris.
        • 1. Re: FillColor of a Rectangle is Swatch("None")
          Kasyan Servetsky Level 5
          Hi Chris,
          Here is what came into my mind:


          var myDoc = app.activeDocument;
          // I assume that the rectangle is  selected
          var myRectangle = myDoc.selection[0];
          var myColor = myRectangle.fillColor;
          var myColVal = myColor.colorValue;
          if (myColor.space == ColorSpace.RGB) { // for RGB
             alert("Color of rectangle is R=" + myColVal[0] + " G=" + myColVal[1]  + " B= " + myColVal[2] );
          }
          else if (myColor.space == ColorSpace.CMYK) { // for CMYK
             alert("Color of rectangle is C=" + myColVal[0] + " M=" + myColVal[1]  + " Y= " + myColVal[2] + " K= " + myColVal[3]);
          }
          else if (myColor.space == ColorSpace.LAB) { // for LAB
             alert("Color of rectangle is L=" + myColVal[0] + " a=" + myColVal[1]  + " b= " + myColVal[2] );
          }

          Kasyan
          • 2. Re: FillColor of a Rectangle is Swatch("None")
            bART2007 Level 1
            The problem is that in my situation myRectangle.fillColor a Swatch returns (and not a Color). Since it's not possible to request the colorValue of a Swatch, I don't know how I can find those values.

            Chris.