Illustrator :: Scripting - How To Remove Swatch In CS5
Oct 10, 2012
Swatches Swatches Read-only. The swatches in this document.
Deletes a swatch from the current document
Set appRef = CreateObject("Illustrator.Application")
Set documentSwatches = appRef.ActiveDocument.Swatches
Set swatchToDelete = documentSwatches(5)
swatchToDelete.delete
How am I supposed to be able to make changes to the swatches collection - it is read only...
Not supprisingly I have failed to implement this in C-sharp
Is there anyway in JavaScript to replace one swatch with another?
I've seen other posts where similar questions have been asked, but the solution seems to involve iterating over all the pageItems, testing and then changing the fillColor.
All I want to do is delete/replace a specific color. Say replace Yellow with Green.
Is there a way of doing this without recursing through all of the page items?
I'm needing to loop through each character of a text frame and check the color of each character. Is it possible to get the swatch name of each character? Or can you only get the red, green, blue values?
I'm writing a script to create a new AI document with a restricted swatchbook. The designer is supposed to use only the swatches/inks provided by this script. So far I was able to delete all current swatches and add a CMYK or RGB spotcolor swatch.
var inkt02 = app.activeDocument.spots.add(); inkt02.name = 'inkt 2'; inkt02.colorType = ColorModel.SPOT; var kleur02 = new CMYKColor(); kleur02.black = 10; kleur02.cyan = 80; kleur02.magenta = 0; kleur02.yellow = 90; inkt02.color = kleur02; var newSpotColor = new SpotColor(); newSpotColor = inkt02; newSpotColor.tint = 100; thePallet.addSpot(newSpotColor);
Often we will be dealing with Pantone colors. No need to define these, as they are inside AI already, right? But how to call them from the library? I'm new to ExtendScript.
I have a list of 300+ colors that I need to make into a swatch library for Illustrator. The data looks like this:
GREEN GRASS,127,187,0 PALE YELLOW,241,235,135 LIGHT YELLOW,238,231,93 DAFFODIL,249,231,21 MOONBEAM,249,223,22 etc.
It's RGB I think. In any case, I am just starting with Illustrator and I know NOTHING about scripting. these colors into a swatch library? I am getting a migraine just thinking about putting them in one by one.
I found something here, but that didn't work for me. I get an error on processing on line 75. [URL] ....
Error 24: app.doScript is not a function, Line 75 _> app.dpScript(speakThis, 1095978087); //AppleScript.
I get as far as choosing the csv file, and then I get the error. I think this outputs as CMYK, but not sure.
I'm trying to challenge myself here, I want to create a copy of every gradient in the active document and give it an assigned name like "Batman 1" "Batman 2" ect.
I can add new gradients and set their stop colors ect but I can't figure out how to create a perfect copy of the gradient in the swatch library.
I've been looking and the only thing I found that comes close was an older script that's only compatibale with CS. In this they're copying EVERYTHING I just wanna stick to gradients at the moment. Here's the link: [URL]
I looked to this as an example of how to do something like this but since it wont work with CS6 I cant really experiment or tinker to figure out how it works.
i want to get the swatch color of active document . i use 3 to 4 colors both cmyk and pantone which is in swatches now i want to get their values using script.
I recently created a script that reads the layer names of an Illustrator file, and uses the name to identify a swatch to use to pattern all elements on that specified layer. The script works well, and is a real time saver for our mapping staff, but it requires duplicate swatches to exist, where the only difference is their colour.
To improve the script I want to duplicate a swatch and modify its' colour before applying it to a specific layer. I think the only way this can be done is via the "placedItems" command. So the code I'm trying to write looks likke this:
for(var s=0; s<slib.length; s++){ // search swatch library var pat=slib[s].name; // get swatch name
[Code]...
However I'm struggling to find the correct syntax to make this work.
I tried to add a LabColor with an Illustrator script.
function addLabColorToSwatch(L,a,b,swatchName){ var color = new LabColor(); color.l = L; color.a = a; color.b = b; var swatchgroup = app.activeDocument.swatchGroups.add(); swatchgroup.name = "test swatchgroup from jsx script"; [code]....
The script crashes on the Line 'swatch.color = color;' with "Error 1202: Not implemented"..This seems to a bug. I allready filed it.
I've been looking for scripts online that would create a color swatch legend to list the colors used in my illustrator file. I found this (see below) and tweaked it to place properly on my particular page, but it adds everything in my swatches panel to the legend. Ideally, I'm looking for a piece of script to add that would only add used swatches to the legend, or a script that would only add spot colors to the legend.
var docRef=app.activeDocument; var SwatchBoxSize=24; var swatchBoxSize=parseFloat(SwatchBoxSize); var swatchBoxTop=swatchBoxSize+314;
I have a couple thousand AI authored EPS files with a specific swatch name (SpotBlack) that I would like to rename (black) -- is there any method to do this en masse, preferrably outside of Illy using a text editor?
I have an AI file containing seamless pattern swatches.I'd like to get each swatch vectors (ie : access the swatch groupItem). It's doable when clicking on the swatch panel and dragging the swatch on the document, or even double clicking the swatch in the swatches panel, I'd like to do it with javascript.
how to access swatch patterns properties.
How to access the swatch properties, like when double clicking on the swatch in the swatches panel, how to "simulate" a drag & drop of the swatch to the document, I'll take it too, though I think it is not the most convenient way to do.
I have a large list of custom colors in Excel that has the color name and CMYK breakdown of each color. I'm looking for a way to import this information to create a custom Color Swatch Library. That will have the name of the color and the CMYK breakdown. So that I can easily use in Illustrator and Photoshop. Is there any way or application in doing this with out manually entering the information and creating a new library?
I'm trying to write a script that applies a single swatch to a single path item and repeat for every swatch that is currently contained in the swatch library. This script that I have written is only applying the last swatch in the swatch library to every path item on the page. Currently I'm more concered with getting each swatch that is currently in the swatch library to be applied at least once before worrying about applying the same patch to any extra number of patch items compared to the swatches.length.
// Apply every swatch library color to path items on a page if ( app.documents.length > 0 && app.activeDocument.pathItems.length > 0 ) { doc = app.activeDocument;
I am trying to iterate through objects in a layer and if the object satisfy a condition, I want to remove it.
Problem is that from what I suspect, if I use a "for loop" then when I remove an element, the initial length of the loop becomes invalid by removing the element. So what I would need is to iterate through objects in another matter and I am clueless.
I'm trying to remove all hidden page items regardless of how many sublayers they are burried in. I wrote a snippet here that seems to only partly work. It removes all hidden page items unless two hidden items exist right after each other in the stacking order.
for (i=0; i<doc.pageItems.length; i++){ if (doc.pageItems[i].hidden == true){ doc.pageItems[i].remove(); } }
I am wondering if there is a way to add/remove/redistribute anchor points on a compound shape so that there are evenly spaced anchors along the outline of that shape.I am aware of the "add anchor points" command. But that adds a new anchor at EVERY midpoint between two anchors. It doesn't smartly calculate where to add and where to avoid adding anchors.
I'm try to automate the importing of the Varaible and datasets into my graphs via Scripting, but the ImportVaraibles() function doesn't seem to work. Here is my Script, mostly copied from the example script provided with Illustrator (CS5). And, this works manually, using the file names in the script, via Load Variable Library
Set appRef = CreateObject(strIllistratorVersion)
'Open the file and import the datasets Set docRef = appRef.Open(strTemplate & "200-500.ai") 'docRef.Datasets.RemoveAll docRef.Variables("Yearbook").Delete
Here is the problem, after I delete the previous library, then this next line, right from the example, does nothing The script then exits with 'No Datasets in this document'
docRef.ImportVariables (strXMLFolder & "Lumber_200-500.xml") 'appRef.DoJavaScript "alert('Template:" & strTemplate & strRange & ".ai | XML file:" & strXMLFolder & "" & objFile.Name & "^')" If (appRef.Documents.Count > 0) Then Set docRef = appRef.Documents(1)
[Code]....
If I remove that delete line, the script runs, but just uses whatever Variables I had last loaded, not the XML file.
It's simply not loading. What do I need to do to get it to load?
I opened a PDF in Illustrator and it has 4 Spot color swatches. Two of them will not delete or let me alter them and I need to change them to CMYK. I've tried reopening the document, restarting my computer and copying and pasting everything into a new document. Nothing has worked for me. I've also tried selecting everything, and going to Edit > Edit Colors > Convert to CMYK ... and then making a new color group (with global checked.) Still won't let me edit the two problem swatches. I then went to "Select all unused" from the swatch panel (thinking they would at least get selected because all of the colors should link to my new global color group) and the two problem swatches did NOT get selected. I've tried deleting all the links (thinking maybe the spot color was tucked in an eps file or something.) No objects are locked and none of the layers are locked.
I have downloaded some of Ian symbols which is a zip file and Safety Nut 10° thru 55°. How do I place these files in Illustrators Swatch Libraries. The Safty Nut file has installed itself somewhere?? If I double click on the folder Illustrator starts up an the nuts are there in a window but when I close Illustator and restart Illustratior and look for it in the swatch folders it dose not show up?
I frequently use Pantone solid coated colors in my work, and have to open that palette anew each time Illustrator has been restarted. I know that in CS4 I could keep that palette available, but I haven't been successful doing the same in CS5. I have saved my workspace, but the Pantone palettes disappear when Illustrator quits.
I can not delete some of the swatches (PMS colours) from the dock. I've tried to search for any artwork that may contain the colour, but I could not find anything. When I open Swatch Options it only lets me change Color Mode. Swatch name and color type are greyed out no matter what color mode I choose. I've tried to copy and paste the artwork in a new document, restart Illustrator but the problem persist.
swatch that I have created in illustrator. Once the swatch is applied as a fill there is a white line surrounding the original pattern. I have read other blog posts about the issue that state that the lines are just on screen and dissapear when you export as a PDF and when you print. I printed the design today at three different scales (100%, 40%, 20%) and all showed a white line but only on the horizontal axis. Both horizontal and vertical lines are visible when exported as a PDF. The original design is vector.
Here is a screen shot of the design from my computer:
Here is a photo of what the design looked printed (notice that the white lines are ony visible on the vertical axis):
I'm creating a swatch group in my swatches panel and I can click and drag any color in the swatches panel to my new folder. But it won't let me click and drag the custom gradients into this folder. How do I add my new gradient swatches to the swatch group folder in the swatches panel?
I wanted to save a pattern swatch and not the whole swatch library so I deleted all the swatches until it was just the one pattern swatch. I saved it as an .ase and then opened it in another document. I noticed however that when I open the pattern in the other document it shows the default swatch library and no pattern swatch. When I save the swatch as an ai. it opens the default library as well as the pattern swatch. Is there a way to save just the pattern swatch?