πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #16974

Manipulating color swatches in Applescript

#16974
From: John Darnell
Date: Wed, 09 Jul 2003 14:54
39 lines
2378 bytes
FοΏ½ilte Fellow Scripters:

I am attempting to set the fill color of a rectangle to Cyan. When I look at the swatch panel in InDesign, it has, among others, the following colors:

C=100 M=0 Y=0 K=0
C=0 M=100 Y=0 K=0
C=0 M=0 Y=100 K=0

Okay, the first is obviously cyan, the second magenta, and the third yellow. The displayed names, however, are awkward.

I went in and attempted to change the names of these colors to cyan, magenta, and yellow, respectively, but when I did I receive the error message, "Reserved swatch name. Please choose another."

"Okay," I reasoned, "This means that I can use these names in a script--at least to see what will happen." So I built this little script to test my theory:

tell application "InDesign"
set TheColor to swatch "cyan"
tell active document
tell last page
tell last rectangle
set fill color to TheColor
end tell
end tell
end tell
end tell

I have a document up with a single page in it and a single rectangle on the page. When I run the above script I get the error message, "InDesign got an error: Can't get swatch 'Cyan'"

If I move the second line (set TheColor, etc.) until after the "tell active document" I get a message telling me "InDesign got an error: Can't get swatch 'Cyan' of active document"

One other note: if I run a completely separate script looking something like this:

set colorlist to name of every color
return colorlist

I get a list of the names of colors in the document/InDesign. Cyan is definitely on that list.

If I have to use the C=100 M=0... designations I will, but it seems to me that there ought to be a way to use cyan if it is on the list. What am I doing wrong?

TIA.
Technical Details
Message-ID: <1de9d8b1.-1@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f939a,90465f8c1b0c18b8,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-07-09 08:08:03 PST
From: "John Darnell" <John.Darnell@Walsworth.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Manipulating color swatches in Applescript
Message-ID: <1de9d8b1.-1@WebX.la2eafNXanI>
Date: Wed, 9 Jul 2003 07:54:39 -0700
Lines: 54
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit