How do I script Illustrator to get a PANTONE swatch from a swatch library

I've been searching high and low, but cannot find the answer to this question.  Quite simply, I need a script to convert all PANTONE spot colors in an Illustrator file into their CMYK equivalents fromthe PANTONE BRIDGE book.
In order to accomplish this, however, it would seem necessary for the script to search through the various PANTONE swatch library color books to find the one I'm looking for.  I have a String of the one I need, but I don't see how ExtendScript can search within the various swatch libraries (or even just the one library—"PANTONE+ Color Bridge (Un)Coated".  I can only seem to look at swatches that are in the main "Swatches" palette using Document.swatches.  Any ideas?

I'm afraid that code gives me an 'MRAP' error in the ESTK.  But, I have actually found a way around the problem by utilizing your original suggestion of having a separate file with all of the Pantone swatches added to it so the script can grab that swatch, grab its getInternalColor, turn it into a CMYKColor, then assign the values retrieved from getInternalColor to the new swatch's four Color properties.
Yes, it's a bit of a roundabout method and takes a lot of code, but it gets the job done quickly, and that's what I need.  Here's the code I have (The "workDoc" has already been assigned to the currently open document.):
// To finish up, we delete the other two layers beyond the first and then save the file for use as digital printing file.
// First, delete the two layers.
workDoc.layers[2].locked = false;
workDoc.layers[2].remove();
workDoc.layers[1].locked = true;
//          workDoc.layers[1].remove();
// Before grouping and mirroring all of the artwork, it's time to convert all spot colors to process
// using the PANTONE Bridge book as a reference.
// First, let's open up the reference document that has all of the PANTONE Bridge book colors as swatches.
var bridgeDoc = app.open(File("~/Documents/PantoneBridge.ai"));
// Since attempting to colorize textFrame objects seems to crash Illustrator, we're best off just converting them all to paths anyway.
var texts = workDoc.textFrames;
for (var t = 0; t < texts.length; t++)
          texts[t].createOutline();
var items = workDoc.pathItems;
for (var i = 0; i < items.length; i++)
          var myPath = items[i];
          if (myPath.fillColor .typename == "SpotColor")
                    try {var procSwatch = workDoc.swatches.getByName(myPath.fillColor.spot.name + "P");}
                              catch (e) {var procSwatch = addProcSwatch(myPath.fillColor.spot.name + "P", bridgeDoc.swatches);}
                    changePaths(myPath.fillColor.spot.name, procSwatch.color);
          if (myPath.fillColor.typename == "GradientColor")
                    for (var g = 0; g < myPath.fillColor.gradient.gradientStops.length; g++)
                              var gStop = myPath.fillColor.gradient.gradientStops[g].color;
                              if (gStop.typename == "SpotColor")
                                        try {var procSwatch = workDoc.swatches.getByName(gStop.spot.name + "P");}
                                                  catch (e) {var procSwatch = addProcSwatch(gStop.spot.name + "P", bridgeDoc.swatches);}
                                        changePaths(gStop.spot.name, procSwatch.color);
          if (myPath.strokeColor .typename == "SpotColor")
                    try {var procSwatch = workDoc.swatches.getByName(myPath.strokeColor.spot.name + "P");}
                              catch (e) {var procSwatch = addProcSwatch(myPath.strokeColor.spot.name + "P", bridgeDoc.swatches);}
                    changePaths(myPath.strokeColor.spot.name, procSwatch.color);
          if (myPath.strokeColor.typename == "GradientColor")
                    for (var g = 0; g < myPath.strokeColor.gradient.gradientStops.length; g++)
                              var gStop = myPath.strokeColor.gradient.gradientStops[g].color;
                              if (gStop.typename == "SpotColor")
                                        try {var procSwatch = workDoc.swatches.getByName(gStop.spot.name + "P");}
                                                  catch (e) {var procSwatch = addProcSwatch(gStop.spot.name + "P", bridgeDoc.swatches);}
                                        changePaths(gStop.spot.name, procSwatch.color);
var rasters = workDoc.rasterItems;
var bitmapFound = false;
var checkForTint = false;
for (var i = 0; i < rasters.length; i++)
          var myRaster = rasters[i];
          if (myRaster.channels == 1 && myRaster.colorizedGrayscale) {if (myRaster.colorizedGrayscale) {bitmapFound = true;}}
          else if (myRaster.channels < 4 && myRaster.colorizedGrayscale)
                    if (/^PANTONE/.test(myRaster.colorants[0]))
                              try {var rastSwatch = workDoc.swatches.getByName(myRaster.colorants[0] + "P");}
                                        catch (e) {var rastSwatch = addProcSwatch(myRaster.colorants[0] + "P", bridgeDoc.swatches);}
                              changeRasters(myRaster.colorants[0], rastSwatch.color);
if (bitmapFound) {alert("Found at least one colorized raster image in the Digital file.  Please manually change their colorants to CMYK.\nPlease see Chris McGee for more information.");}
if (checkForTint) {alert("At least one raster image in the art has been converted to CMYK.  However, if its former spot color was tinted less than 100%, then you will need to manually change the colorant in the Digital file to match.\nPlease see Chris McGee for more information.");}
// We should be done now with the PANTONE Bridge reference document, so close that.
bridgeDoc.close(SaveOptions.DONOTSAVECHANGES);
app.redraw();
function addProcSwatch(swatchToGet, docSwatches)
          var bridgeSwatch = docSwatches.getByName(swatchToGet);
          var newSwatch = workDoc.swatches.add();
          var spotName = bridgeSwatch.color.spot.name;
          var spotValue = bridgeSwatch.color.spot.getInternalColor();
          newSwatch.color = CMYKColor;
          newSwatch.name = spotName;
          newSwatch.color.cyan = spotValue[0];
          newSwatch.color.magenta = spotValue[1];
          newSwatch.color.yellow = spotValue[2];
          newSwatch.color.black = spotValue[3];
          return newSwatch;
function changePaths (colorName, newColor)
          var allItems = workDoc.pathItems;
          for (var j = 0; j < allItems.length; j++)
                    var thisPath = allItems[j];
                    if (thisPath.fillColor.typename == "SpotColor" && thisPath.fillColor.spot.name == colorName)
                              var thisTint = thisPath.fillColor.tint / 100;
                              thisPath.fillColor = newColor;
                              thisPath.fillColor.cyan *= thisTint;
                              thisPath.fillColor.magenta *= thisTint;
                              thisPath.fillColor.yellow *= thisTint;
                              thisPath.fillColor.black *= thisTint;
                    if (thisPath.fillColor.typename == "GradientColor")
                              for (var g = 0; g < thisPath.fillColor.gradient.gradientStops.length; g++)
                                        var gStop = thisPath.fillColor.gradient.gradientStops[g];
                                        if (gStop.color.typename == "SpotColor" && gStop.color.spot.name == colorName)
                                                  var thisTint = gStop.color.tint / 100;
                                                  gStop.color = newColor;
                                                  gStop.color.cyan *= thisTint;
                                                  gStop.color.magenta *= thisTint;
                                                  gStop.color.yellow *= thisTint;
                                                  gStop.color.black *= thisTint;
                    if (thisPath.strokeColor.typename == "SpotColor" && thisPath.strokeColor.spot.name == colorName)
                              var thisTint = thisPath.strokeColor.tint / 100;
                              thisPath.strokeColor = newColor;
                              thisPath.strokeColor.cyan *= thisTint;
                              thisPath.strokeColor.magenta *= thisTint;
                              thisPath.strokeColor.yellow *= thisTint;
                              thisPath.strokeColor.black *= thisTint;
                    if (thisPath.strokeColor.typename == "GradientColor")
                              for (var g = 0; g < thisPath.strokeColor.gradient.gradientStops.length; g++)
                                        var gStop = thisPath.strokeColor.gradient.gradientStops[g];
                                        if (gStop.color.typename == "SpotColor" && gStop.color.spot.name == colorName)
                                                  var thisTint = gStop.color.tint / 100;
                                                  gStop.color = newColor;
                                                  gStop.color.cyan *= thisTint;
                                                  gStop.color.magenta *= thisTint;
                                                  gStop.color.yellow *= thisTint;
                                                  gStop.color.black *= thisTint;
function changeRasters (colorName, newColor)
          var allRasters = workDoc.rasterItems;
          for (var j = 0; j < allRasters.length; j++)
                    var thisRaster = allRasters[j];
                    if (thisRaster.channels > 1 && thisRaster.channels < 4 && thisRaster.colorizedGrayscale)
                              if (/^PANTONE/.test(thisRaster.colorants[0]) && thisRaster.colorants[0] == colorName)
                                        thisRaster.colorize(newColor);
                                        checkForTint = true;
// That concludes all of the color-changing steps.
I hope this helps anyone else who is running into this (admittedly unusual) situation.

Similar Messages

  • How the client machine could to get the combo update from SUS?

    Hi everybody!
    How the client machine could to get the combo update from SUS? My SUS working for clients comp and showing the Mac OS X 10.6.5 Update - not Combo Update (Combo Update downloaded also and I can see it in Server Admin)! But I would like to install the Combo Update - is it possible? How I can get the Combo Update if it is not shown in the list?
    Thank you in advance!

    You can download the Combo manually from Apple.
    http://support.apple.com/kb/DL1324
    http://support.apple.com/downloads/DL1324/en_US/MacOSXUpdCombo10.6.5.dmg

  • HT4623 I have sent my i phone through royal mail on 8th February 2013 but still it is not deliver to apple. I used the empty box sent by apple to me sent my i phone to them. Can any one advice me how long it can take to get back my iphone from repair?

    I have sent my i phone through royal mail on 8th February 2013 but still it is not deliver to apple. I used the empty box sent by apple to me to sent my i phone to them. Can any one advice me how long it can take to get back my iphone from repair?

    moynul82 wrote:
    but still it is not deliver to apple.
    If Apple has not received your phone, obviously it can't even be evaluated for warranty purposes. Have you tried calling AppleCare to verify whether they have received the phone or not?

  • How do I delete one song or an entire album from my iTunes library?

    How do I delete one song or an entire album from my iTunes library?

    Click on it from your library.  Press the delete key on your keyboard

  • HT5824 how do i permanently remove a song that i purchased from my itunes library ?

    how do i permanently remove a song that i purchased from my itunes library on my iphone 5s ?

    Unfortunately that was empty too. The Firefox upgrade at that time seemed to wipe an awful lot of stuff. After searching, re-installing etc, whatever was suggested, I gave up. It was a while back. I will remember your suggestions if it ever (hopefully not) happens again though. I did have a very old bookmarks backup, but that would not import, so I did use bits of it manually but it had saved as a massive merged line of sites without my folders, so was a bit too much to fiddle with. The loss of the classical music sites was what I regretted most, no idea what they were called and cannot find some of them now. Ah well, no point in fretting about it now I suppose.

  • Missing swatches from my Pantone+ swatch library in Illustrator (CS6) on a Mac.

    Has anyone else ever been missing swatches in Illustrator for PMS colors? My client has specifically requested PMS 2230C. It is not available in my swatch library of Pantone+ solid coated swatches. I also looked for the color above it, #2229 from the same page of the printed swatch book. It too is missing. Anyone know of a fix or where specifically I can download a new swatch library file?

    Here's a discussion from the InDesign forum that should answer your question:
    Re: 336 new pantone colors

  • How do I get a purchased ringtone from my music library to Ringtones?

    I've purchased a couple of ringtones from itunes but they downloaded into my music library and I can't figure out how to move them to the Ringtones folder in my library. I tried going back to itunes and downloading them directly onto my phone but they show "purchased" and will only play, not download.
    TIA
    alice

    No, what I actually purchased was a ringtone.  I actually purchased it on my iphone from contacts by selecting a contact, clicking edit, clicking ringtone, clicking "buy buy more tones", being taken to the "tones" section of the itunes store, finding the tone I wanted in the "tones" section of the itunes store and buying it.  It download as an m4r file and remains in m4r file.  Unfortunately, no matter what I do, I cannot get this m4r ringtone file that I purchased from the itunes store "tones" section from the music folder in itunes media to the ringtones folder.

  • I need to know how to get a particular photo from my iPhoto library that is backed up on Time Machine.

    I just backed up my whole computer on an external drive with Time Machine.  I wanted to clean off my old files from my computer, but I didn't want to erase them until I knew I could go back and get particular items from the back-up.  For example if I clean out my iPhoto libraries, how would I go get the libraries once they are on the external drive.
    I want to clean out my photos without having to put them all on CD's.  Can I use an external drive as my drive I save everything to not just for a system back-up.  Or is there a better way to store my photos rather than CD's so I can clean-up some memory space on my internal drive.

    ttown wrote:
    I just backed up my whole computer on an external drive with Time Machine.  I wanted to clean off my old files from my computer, but I didn't want to erase them until I knew I could go back and get particular items from the back-up.
    No, No, No, a thousand times, no!
    Pardon the dramatics, but don't do that.  Time Machine will, sooner or later, delete the backup copies of anything that's no longer on your Mac. 
    Plus, of course, if you delete the originals, you no longer really have backups (backup = an extra copy in case something happens to the original). 
    Your best bet might be to get a larger internal HD for your Mac.  Second best would be to get another external HD, format it for a Mac, and move some stuff (perhaps your entire iPhoto library) to it, and let Time Machine back up both your internal HD and the new external.

  • How do i know if i get a student discount from the online purchase of logic pro

    I want to buy Logic Pro, but I can't find it in any apple store in my town, so I'm gonna buy it online. I live in Prague, I came here as an exchange student, originally I live in Turkey. I want to know how to get a discount from the online purchase, I couldn't find it in the website so I would be really glad if you guys helped me!
    Thank you!

    hello Michek :
    not sure you can get "student discount" for this app.  you will have to ask more detail from your Apple representative. 
    when you click/ order some merchandise from the Apple store (https://store.apple.com), there's link at bottom of page (like "Apple Store US," "Education Store," "Business," or "Government Store").  you click on the [Education Store] & in the prompt you enter the name of your university/school.  but Logic Pro is not purchased here.
    you have to purchase Logic Pro from the App Store... and APP store doesn't have [Education Store] link.  so your Apple representative in Prague may have a different way to complete this.  or Apple World Wide.

  • How long does it take to get my X61 checked from water spill?

    Hi,
    I had spilled some water into my X61 yesterday.
    Though I instantly shut it down and try to clean, I was too stupid to try to boot it in ten minutes.
    Not sure if it is "OK" right now....
    Does anyone have the same experience?
    Could you share how long does it take you to have your laptop shipped and checked at lenovo repair center?
    Thanks a lot!

    do you have accidental damage warranty? if you don't then you will incur a hefty bill. The check up should not take more than 5 days including shipping, provided that no parts need to changed, if there is parts that are required, then depending on the parts availability, you could wait up to a month or two. 
    Regards,
    Jin Li
    May this year, be the year of 'DO'!
    I am a volunteer, and not a paid staff of Lenovo or Microsoft

  • How do I get the iBooks App from my iTunes library in the PC to my iPad?

    I went into the itunes store from my PC, then downloaded the iBooks app. It wwas successful, but when I sync my iPad to the iTunes library, I don't get the app. Why? Do I need to get a separate internet service for my iPad alone so I can access the iTunes store from the iPad? Or is there a way for me to get the iBooks from the library in the PC to my iPad? I'm so confused, and I'm a new apple product user.
    Any help's appreciated

    There is no option for a check mark in there. I just tried. I can see the iBooks app under Library>Applications, but there's no option for me to check it.
    I tried switching to all the viewing modes, and it still doesn't appear.

  • How to sinc two computers and get all the files from both

    Not sure if this is the right forum for the issue, but... I have a iMac G5 and a MacBook, and I use one or the other for my work. That way I get part of my work on one, and other part on the other Mac. Now, I would like to sinc both of them, so that I have all the files from iMac on the MB, vice versa. I know that I could go slowly and use an external hard drive, copy files from one computer, save on another, but is there any handier and faster way to do it?
    Thanks
    Zo

    http://docs.info.apple.com/article.html?path=Mac/10.4/en/mh664.html
    http://docs.info.apple.com/article.html?artnum=106461

  • How to use FQL & Coldfusion to get the latest comments from the Facebook commentbox

    Hi all,
    I have a facebook commentbox on my website, now i want to get the latest comments so i can show them on the frontpage to encourage people to comment.
    After searching the net for hours and hours i can't seem to find any real solution.
    Does anyone already has something like this setup and like to share the insights?
    Thanks!

    You can extract a date portion and  assign to the variable and then compare with GETDATE()
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How much would it cost to get earbud end removed from the jack on my MacBook??

    Ear bus end broke off into jack on my MacBook awhile ago. The laptop's warranty is over, so I was just wondering how much it would cost to bring it to an Apple store to have it removed?:) thanks!

    We are only end-users like you, not Apple employees, so any replies here would be pretty much a guess. Give the nearest store a call and ask. I'm sure that is a repair they encounter often and can probably quote a price over the phone.

  • How much will it cost to get my ipod fixed from water damage?

    The steam from my shower has got into my Ipod and now it wont work. The buttons work and things, but the touch screen doesn't. i was wondering if anyone knew if apple with replace or fix it it for me and they do how much it will cost

    Apple will exchange your iPod for a refurbished one for (USA) $99 for 16 GB 5G and $149 for the other 5Gs. They do not fix yours.
      Apple - iPod Repair price                             
    First I would try placing the iPod in a sealed container of rice and change the rice periodically.

Maybe you are looking for

  • Labview graph scale labels do not update

    I am using XScale.NameLbl.Text and YScale.NameLbl.Text graph properties to programmatically change the labels on the X & Y axis. It seems to work when I run the subVI containing the graph, but when the subVI is placed in an application, they do not u

  • Macbook Core 2 Duo Excel 2008 Not Responding

    I have a Macbook Core 2 duo with Snow Leopard. I have Microsoft Office 2008 and recently my computer is running slow, but now excel will not load at all. It shows the color wheel and then the "application does not respond". What should I do

  • Find duplicates using EXIF data

    Is there any way to find duplicates of images in iPhoto or just on my desktop using the EXIF data on the images. I have a folder of around 4000 images that i recovered (after my hard drive went down) and now i'm left with the terrible task of trying

  • Date losing HH:MM:SS

    I'm using a oracle.jbo.domain.Date class to persist absolute time/date stamps; these are supposed to be used to trigger execution of an activity at a later date. Unfortunately, I'm seeing the time component being truncated from the Date when it's per

  • Downloading Dreamweaver CS6

    I am a student at oakland county community college I need Dreamweaver CS6 for my Webdesign class. Whenever I try to download it I keep getting Dreamweaver CC. I need CS6 how can I get it?