Selecting unused color swatches using applescript?

I cannot seem to remove unused colors from my swatches palette... got any suggestions?..
here's a few sample of what i've done so far...
    --set ColorWell to every page item of group item 1 of layer "Image Layer" of current document as list
    --set ColorList to {} as list
    --set ColorList to name of every swatch of selection
    set ColorList to name of every swatch of imposition as list
    set ColorList2 to name of every swatch of current layer as list
    (*repeat with EachItem in ColorWell
        set ColorList to ColorList & (name of fill color of EachItem as string) as list
    end repeat*)
    --log ColorWell
    --log ColorList
    (*repeat with EachColor in ColorList
        if not (exists name of swatch EachColor) then
                delete swatch EachColor of current document
        end if
    end repeat*)
    (*repeat with EachColor in ColorList
        --if swatch EachColor exists then
        if page items of ImageLayer contains {fill color:EachColor} then
            return
        else
            delete swatch EachColor of current document
        end if
        delay 1
    end repeat*)
    (*set PossibleColor to 1
    repeat (count swatches of current document) times
        if swatch PossibleColor of ImageLayer exists then
            return
        else
            delete swatch PossibleColor of current document
        end if
        set PossibleColor to PossibleColor + 1
    end repeat*)
thanks...

Try this:
tell application "Adobe Illustrator"
set myswatches to every swatch of document 1
repeat with myswatchnum from (count of items in myswatches) to 1 by -1
set myswatch to item myswatchnum of myswatches
try
set myfilledpaths to (path items of document 1 whose fill color = (color of myswatch))
if myfilledpaths is {} then
set mystrokedpaths to (path items of document 1 whose stroke color = (color of myswatch))
if mystrokedpaths is {} then
try
delete swatch myswatchnum of document 1
end try
end if
end if
end try
end repeat
end tell

Similar Messages

  • InDesign CS4 crashes when selecting New Color Swatch

    Any idea why InDesign would be crashing when I select New Color Swatch?  I can Load Color Swatches or choose from the swatched in the menu, but if I try to add a new color it crashes no matter what type of document I am working on.

    This is the sort of error, if happening in all files, that is usually fixed if you Replace Your Preferences

  • Getting Selected Project in Aperture using AppleScript

    Is it possible to get a reference to the currently selected project in Aperture using AppleScript? In other words, is it possible to get the project containing the currently selected image (which I can get by using "selection")? If possible, how can I do it?

    GIve this a try:
    tell application "Aperture"
    set x to selection
    set x to item 1 of x
    tell library 1
    get value of other tag "MasterLocation" of x
    end tell
    end tell
    One thing that helps to answer similar questions is to ask for properties of objects. That can reveal more about an object. Another way to help answer these kinds of questions is to ask for available tags in Exif, IPTC, and "other tags" of a particular image version. That will tell you all the available tags that have values assigned for a particular image version. You can then explore those tags to see if what you are looking for is available.
    Hope that helps.
    Message was edited by: lenny

  • I am trying to load a PMS Coated color swatch using InDesign CC and it indicates it does not exist...

    When I go to "New Color Swatch", then to "Pantone+ Solid Coated" Color Mode, Spot Color, and enter "582" it automatically adjusts to "5825". Indicating that there is no "PMS 582 C" – but there is a 582 C. What am I doing wrong?

    hello, you can install the flash plugin from https://get.adobe.com/flashplayer

  • How do I select similarly colored text using the magic wand?

    I converted a large document from RGB to CYMK (File | Document Color Mode). I'd like to select all of the text that was RGB(0,0,0) and is now CMYK(75.02,67.97,67.02,90.16) so I can change it to CMYK(0,0,0,100). I think the magic wand is the way to do this (correct me if I'm wrong).
    I have text in a dozen or more text areas. Many of the text areas overflow text into another text area. Some of the text in the text areas is "black" but there is also text with other colors that I'd like to remain unchanged.
    For example, I'd like to select all of the black text in the following two text areas without selecting the red text. I thought  that I could click on the black text and have all the black text (but not the red text), selected, but the entire text box is selected (and nothing in the second text box is selected). Can the wand select some text within several text boxes? If not, how should I go about changing the black? Thanks.

    Thanks Mylenium.
    If I use the Same Fill command, it does select both text areas. But if I then choose a replacement color (e.g., CMYK(0,0,0,100)) all of the text in both text areas is changed to black (i.e., the red text in my above illustration also changes to black).

  • Change selected file in automator using applescript ???

    So I'm getting better at using Automator to create useful Services but still a bit of a newbie with doing powerful things with AppleScript... and I think this task requires some applescripting. Here's what I want to do:
    1. Based on a selected text file I want to run a pre-existing script that converts this file into an HTML file. This new file has the same name as the text file but has the .html extension rather than the .txt extension. (This step is easy enough with Automator and it works just fine already.)
    2. BUT NOW, I want to take that resulting HTML file and run another pre-existing script that converts the HTML file into an RTF file. The problem is that I basically want to change the selection from selectedfile.TXT to selectedfile.HTML so that I can proceed to this next step...
    3. AND THEN, I want to launch an app with this resulting RTF file. Again, I need to change the selection to selectedfile.RTF.
    Right now this requires me to run three different automator services, and changing the selected file between each step... But I'm sure there's an easy applescript way (or other way) to do this using just one service -- probably involves some filename parsing and some magic to change the selection??? -- or something like that...
    Could anyone point me in the right direction???
    Thank you thank you thank you!
    ~zyyyy

    Have you considered using a bash script? You can even write the script in an Automator Service.
    Open Automator and select Service from the main screen. Set the ‘Service Receives Selected’ pop-up menu to Files or Folders, and set the ‘in’ pop-up to Finder. Drag Run Shell Script from the Utilities section of the actions library into the workflow area. Set Pass Input to As Arguments. Replace the sample code in the input area with this:
    for f in "$@"
    do
    file_ext="${f##*.}"
    if [ $file_ext = "txt" -o $file_ext = "TXT" ] ; then
    /usr/bin/textutil -convert html "$f"
    /usr/bin/textutil -convert rtf "${f/$file_ext/html}"
    /usr/bin/open -a /Applications/TextEdit.app "${f/$file_ext/rtf}"
    fi
    done

  • Color Swatch Palette is Stuck

    I am a designer working for a printer. We have a customer who is trying to add a new color to her CS4 document. She is selecting New Color Swatch - Spot - Pantone Solid Coated but is getting Process Coated DS colors -- the palette is stuck. Any suggestions? When she sent the document to me I didn't have any problems with the swatch palette.
    Thanks for any help.

    from the help files:
    Restore all preferences and default settings
    When InDesign is behaving erratically, deleting preferences (also referred to as “trashing preferences” or “removing preferences”) often solves the problem.
    Do one of the following:
    (Windows) Start InDesign, and then press Shift+Ctrl+Alt. Click Yes when asked if you want to delete preference files.
    (Mac OS) While pressing Shift+Option+Command+Control, start InDesign. Click Yes when asked if you want to delete preference files.

  • Crash after trying to remove unused colors

    When selecting the panel-menu 'select unused colors' and trying to remove them, Indesign CS4 and CS5 both crash, this is happening for a while now, it is not a major problem, but I was wondering of other people have similar experiences?
    This is happening in both versions, in new and older documents, perhaps it is something plug-in related? The only third party plugins installed are
    the Fontagent plugin and the HP Smartstream plugin (this is only in CS4).
    My mac is a MacPro, with 4 Gb RAM, 10.6.4

    Have you tried disabling the plugins? Help>Manage Extensions (CS5) and I there is something similar in CS4 under the help menu
    If it's happening to all documents new and old then try resetting your preferences - http://forums.adobe.com/thread/526990
    If that doesn't work then try this on documents it is happening to - http://forums.adobe.com/thread/526991

  • Swatch palette becomes full of unused colors when copy and paste from one document to another!!

    sometimes (i haven't found a pattern yet of when) when i copy and paste an object that is solid black (for example) into another Illustrator document, a bunch of unused swatches copy into the swatch palette for no reason! lots of "default global colors" and PMS swatches. i then have to 'select all unused' and delete them all to clean out the palette (which always seems to stall while thinking when selecting or deleting them). often times i get the global swatch warning (always 2x, not just once) before placing an object and before the whole swatch palette fills up with unused colors.
    this has only happened recently in the last few months and i have been using Illustrator for years so i'm not sure what's stemming this. a new update? has anyone else noticed this problem and know a solution? is there a preference checked somewhere that i don't know about?
    guess i should mention i'm on CS3 Illustrator running MAC OS 10.5.6
    thanks,
    kim

    I've had this problem before as well and it has to do with a currupt file that your coppying from. It's too complicated to explain here so here is my fix for it.
    I take the file and save it down or up in CS1. Open infected file in CS1. Create a new file in CS1 the same size as the one you've opened. Select all and drag and drop into the new empty file. Don't copy paste, it must be dragged into the file. You can then delete all global colours and save your file. The curruption will be gone. There's a way to check suspect files to see if they have the deleted global colours present. Open your suspect file in a text editor like simple text, scroll down a little way and if you see a bunch of lines of code mentioning "deleted global colours" then you know it's infected and has to be fixed.
    Hope this helps
    Here is another idea from a bit of research I just did. Don't know if this works or not but you might want to give it a try and it explains the issue in more detail
    http://adobe.groupbrowser.com/t177412.html

  • How to use AppleScript to set "character fill color" in Pages 5.2?

    For Pages 5.2 on OSX 10.9.3, what is the correct applescript for changing the "character fill" of text in pages. 
    If you highlight text, you do this via your mouse in the inspector by clicking "style," "advanced option (the gear wheel to the right of bold, italics, and underline), "character fill color (clicking on the multi-color circle, not the dropdown menu), and then choosing a color that comes up in the "colors" dialogue box.
    I've looked all over and cannot find how to use applescript to set the character fill color in pages. 
    In some examples (not directly related) I see "character fill" used. 
    In others, I see "colorfill." 
    Basically, I want to use applescript, embedded in a keyboard maestro macro, to change the background color of the text (not the text color itself) to particular colors. 
    Given the changes and updates to Pages this year, and to applescript, what's the easy way to do this?
    Thanks!
    Chuck

    Pages v5.2 still does not include selection-object, or character background color entries in its AppleScript dictionary, as does Pages ’09. Indirectly, using System Events, you can get the text selection in Pages v5.2, but then you can do nothing to change the selection. No assurances as to if or when Apple will mature the AppleScript dictionary support for Pages v5 series.

  • How to make a spot swatch with specific name by using AppleScript?

    Hi there,
    I am trying to create a script in AppleScript to make a new spot color swatch that must be the COLOR TYPE : SPOT (with specific values). I've got it to make a global process color but can't seem to make a spot swatch. I'm using the script below :
    tell application "Adobe Illustrator"
        set docColorSpace to color space of document 1
        if (docColorSpace is CMYK) then
            set SpotColor to {cyan:100.0, magenta:0, yellow:0.0, black:0.0}
        else
            set SpotColor to {red:0.0, green:174.0, blue:239.0}
        end if
        make new spot in document 1 with properties {name:"ADHESIVE", color:SpotColor}
    end tell
    I did find an entry in an old forum that did this using javascript, however, I am not experienced with this at all and have no idea what or how to use it on a mac platform. This script is listed below.
    #target illustrator
    var docRef = app.activeDocument;
    var newCMYK = new CMYKColor();
    newCMYK.cyan = 100;
    newCMYK.magenta = 0;
    newCMYK.yellow = 0;
    newCMYK.black = 0;
    var thisSpot = docRef.spots.add();
    thisSpot.name = 'ADHESIVE';
    thisSpot.color = newCMYK;
    thisSpot.colorType = ColorModel.SPOT;
    Any help would be greatly appreciated.
    Thank you!

    You are close but missing the last property listed in the JavaScript… It translates to… 'color type:spot color'
    tell application "Adobe Illustrator"
    set docColorSpace to color space of document 1
    if (docColorSpace is CMYK) then
    set SpotColor to {cyan:100.0, magenta:0, yellow:0.0, black:0.0}
    else
    set SpotColor to {red:0.0, green:174.0, blue:239.0}
    end if
    make new spot in document 1 with properties {name:"ADHESIVE", color:SpotColor, color type:spot color}
    end tell
    BTW… The use of JavaScript in the CS apps is more common because of its 'platform independence' There is a toolkit supplied along with the CS install.

  • Select by Note using Applescript

    I want to know if it's possible using Applescript to select items based on the contents of the Note field of the Attibutes Panel. It's used to select objects within Actions, so it seems like it should be possible.
    Unfortunately I'm not very good at scripting and can't seem to figure out the right syntax.
    Thanks in advance for any ideas or suggestions...
    Mike D.

    Hey, Mike:
    Yes, it's possible to select an item based on the contents of its Note.
    every page item whose note contains "testing" -- This would return a list of page items who has "testing" in the note. This includes an item with the word "retesting" so remember to be specific. These are only computers after all… they're not very smart! ;^)
    This is doable but remember you can name any and all items on a page and select them based on that parameter. Unless you have a particular reason to use the Note property I would use Name but either way can be worked out.
    Cheers,
    storm371

  • Can In Design CS 5.5 locate which page uses a particular color swatch?

    In Design has powerful search abilities.  It can even find where a STYLE is used inside a document with many pages/
    Can In Design CS 5.5 locate which page uses a particular color swatch?

    Maybe. Try Find/Change, Object tab, or look at the Blatner Tools plugin

  • HELP !  why doesn't color picker select specific color ? i make secondary layer and use the tool but no colors are selected and the gray out menu shows nothing !

    HELP !  why doesn't color picker select specific color ? i make secondary layer and use the tool but no colors are selected and the gray out menu shows nothing !
    what am i missing ??!!

    Please add you system info and SpeedGrade version and build number if you actually want help.

  • What controls the color of the cursor that selects text when you use the "Edit Document Text" tool?

    Hi, I have had a student ask me a question I cannot answer: what controls the color of the cursor that selects text when you use the "Edit Document Text" tool?
    I have only seen it appear as a black semicircle over each letter, but at a different computer in our training facility, this same tool appears as an aqua-green highlight.
    Is it a preference I never noticed? Thanks for any info.

    What version of Acrobat? What operating system?

Maybe you are looking for