Monday, April 10, 2006

 

Swatches vs. Colors as properties

In a large number of places in the Scripting Reference, there are color based properties whose Type field reads:
  Swatch, String
with a description that reads: "The color of the <whatever>".

This is correct for setting these color properties (as long as you realize that the string in question should be the name of a swatch of the active document).

But, if you interrogate any of these properties:
  myColor = myWord.underlineGapColor;
you'll get a color object, and not a swatch. To detect whether or not the color object returned is represented in the UI by a swatch, check its name. If the name is "" then the color was explicitly applied to the object in question without using a swatch (I don't think that is possible for the particular example chosen above, but it is certainly possible for such properties as strokeColor and fillColor).

Comments:
well i see we can manually create a swatch but how could we do it using automation
 
This whole thing of swatches vs. colors is a bit mysterious. From a script, if you create a new color, it automatically becomes a swatch. That's why there is no add() method for swatches, but there is one for colors.
 
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?