• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Quark scripting again
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quark scripting again


  • Subject: Re: Quark scripting again
  • From: Stan Cleveland <email@hidden>
  • Date: Tue, 14 Mar 2006 13:30:06 -0800
  • Thread-topic: Quark scripting again

On 3/14/06 12:50 PM, email@hidden wrote:

> Is there any way to script the creation of a custom color?


Here's a handler I wrote for my use. It should handle most situations that
would cause problems. Enjoy!


set colorName to "Red Green"
set cPct to 80
set mPct to 12.5
set yPct to 100
set kPct to 0
set asSep to true -- if false, make spot color
set myColor to makeColor(colorName, cPct, mPct, yPct, kPct, asSep)

on makeColor(colorName, cPct, mPct, yPct, kPct, asSep)
    -- qualify passed parameters
    if (length of colorName) > 63 then -- name is too long
        set colorName to text 1 thru 63 of colorName
    end if
    set {cPct, mPct, yPct, kPct} to ¬
        {cPct as real, mPct as real, yPct as real, kPct as real}
    if (cPct < 0) or (cPct > 100) or (mPct < 0) or (mPct > 100) or ¬
        (yPct < 0) or (yPct > 100) or (kPct < 0) or (kPct > 100) then
        activate
        with timeout of 7200 seconds
            display dialog ("One or more CMYK color values" & return & ¬
                "are out of range:" & return & return & "C:  " & cPct & ¬
                "M:  " & mPct & "Y:  " & yPct & "       K:  " & kPct) ¬
                buttons "Cancel" default button 1 with icon 0
        end timeout
    end if
    -- check if color exists with same callouts
    tell application "QuarkXPress"
        tell front document
            if (exists color spec colorName) then
                set {cFound, mFound, yFound, kFound} to ¬
                    (CMYK color value of color spec colorName) as list
                set {cFound, mFound, yFound, kFound} to ¬
                    {cFound / 655.35, mFound / 655.35, ¬
                    yFound / 655.35, kFound / 655.35}
                set {cFound, mFound, yFound, kFound} to ¬
                    {(round (cFound * 100)) / 100, ¬
                    (round (mFound * 100)) / 100, ¬
                    (round (yFound * 100)) / 100, ¬
                    (round (kFound * 100)) / 100}
                if (cFound is not cPct) or (mFound is not mPct) or ¬
                    (yFound is not yPct) or (kFound is not kPct) then
                    -- Color already exists with different color definition.
                    -- As is, will use existing definition.
                    -- Notify user or take alternate action, if desired.
                end if
            else
                make new color spec at end with properties ¬
                    {name:colorName, CMYK color value:¬
                    {(cPct * 655.35), (mPct * 655.35), (yPct * 655.35), ¬
                        (kPct * 655.35)}, separation:asSep}
            end if
        end tell
    end tell
end makeColor


Stan Cleveland
Color Technology Inc.
Portland, Oregon

"Difficulties increase the nearer we get to the goal." -- Goethe


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Quark scripting again (From: James Weisbin <email@hidden>)

  • Prev by Date: Re: How far back?
  • Next by Date: Re: How far back?
  • Previous by thread: Quark scripting again
  • Next by thread: Photoshop Apple Event timeouts...
  • Index(es):
    • Date
    • Thread