Illustrator Scripting :: How To Place A Swatch Pattern On A Layer
Jan 1, 2014
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 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 been working on a script to place a psd file onto only one visible layer (document has multiple hidden layers). This java code has worked so far:
var doc = app.activeDocument; var onFile = File("C:/Users/Desktop/Desktop/ExportedArtboard-01.psd"); var mydoc = doc.placedItems.add(); mydoc.file = onFile; mydoc.embed();
however this works with only the top layer visible (eye turned on in Ai). if top most layer isn't visible i get "target layer cannot be modified" error.
For instance say i have 1,2,3 layers. layer 1 (top most) and 3 (bottom most) would be hidden, layer 2 (middle layer) would be visible and then running the script would place the psd file on to layer 2.
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 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?
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.
In Illustrator CS4. I want to create a repeating pattern, using a swatch. I've done this before succesfully but not sure why this one isn't working as planned.
The small image at the bottom (just the area inside the artboard) is the spacing I want between the characters, but the pattern at the top is what I get.
I am trying to work out how to rotate a pattern swatch without that rotation affecting all the other pattern swatches on my palette. I don't want the rotation to apply to just one instance of fill, I want to edit the actual swatch so that whenever it is used in the future, that rotation is applied.
I have tried the obvious - eg going to object, transform, pattern only... and it works, but it also rotates all my other swatches; and I can't work out if it's rotating it for just that object or if it's actually updating the pattern swatch orientation.
Additionally some comprehensive tutorials on making patterns using the updated CS6 software - everything I've found so far just raises further questions for me. I'm talking about, for example, being able to change the width or rotation of a stripe within a pattern and have it still tile seamlessly.
It may be the way I'm using this feature and I've just missed it - it appears to me that you can't have a solid background to your swatch because the way it stacks/overlaps elements means that you will end up cropping some elements on some sides.
Try it just by putting a solid shape the exact size of the tile.
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 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 really want to make a small honeycomb swatch pattern (the polygons should be small - 2 px x 2px) , but I just cannot get it to work. What I did is make one small polygon, and went to: Object>pattern>make and applied the following settings:
You will see that on the shoulder of the t-shirt, the pattern is kinda trasparent - the bottom layer is visible-I don't want it to be.The bottom pattern(on the side of the t-shirt) you will see came out fine, except that the polygons are too big and I cannot get it any smaller.
When creating patterns with for example very easy dimensions like the artboard 400 x 400 px etc, and everything right placed, as you can see on the print screens, after having created the pattern, it never aligns center-aligned like I would like it too.
Left: the original positioning before creating the pattern. Right: the result of a perfect square, center aligned to the artboard and with the swatch applied, not too pretty he?
I want to alter the colors of my pattern. Typically, I pull it from the palette to the artboard, change my colors.. re-select the entire patterns repeat and drag and drop it back into the swatches palette. None of my layers are locked and all are visible. What's the deal? (iMac CS2) (I have loaded up other files with patterns in them and it works just fine!) (I have also quit .AI and reloaded the same file with the same problem.)
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 can't figure out how to create outlines (vector lines) for my patterns , as I need to laser cut the pattern, and all the lines have to be seen I use Illustrator CS6.
When making a pattern into a swatch and applying it to letters, I am noticing that you can see an abrupt point where the pattern stops and repeats. How can this be done so it is not visible?
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 have some 2 coluor artwork consisting of 2 x pantone colours purple and grey.
Within the artwork is a stripe pattern swatch consisting of the same colours. On screen the colours are fine and I've checked all the colour settings and these are fine too.
Why however when i print the artwork does the pattern print in a different colour?
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 have created polka dots or even more complicated pattern in previous version illustrator. They are perfect. When i migrated to the CS5, the exactly same pattern always have a fine line in between the pattern swatches. After i export the artwork to jpg in 300dpi, they are still there.
Carlos, you created a script i believe called AI_openMultiPagePDF.However i was wondering if you could change it just a bit and instead of opening the files, could you use the PLACE command instead?
The problem i have had is that some PDF's have embedde fonts that i dont have but if i place it, then flatten transparency>Convert Outlines i can use the PDF excatly as it was and not have it convert the fonts.
I didn't try opening a ridiculous amount of pages, I "only" open 35 pages....in about a minute and a half. Use with caution, save everything before running, script is memory intensive...
// Lion fix by John Hawkinson 01/15/12 START UI CODE, create user interface var win = new Window ("dialog", "MTools - Open Multipage PDF"); [code]....
* this script will prompt the user for a file name and location and then save the current file as a .pdf with secure save options*/ var curDoc = app.activeDocument; var destName = prompt ("Enter a Filename Daniel", "", "Save With Security"); var destFolder = Folder.selectDialog('Select which folder to save to :'); saveFileToPDF(destFolder+ '/' + destName); // not sure if i need this here ?
[Code] .......
i can do the math of (artboard width)-(text width) / 2 is start point of text but how do i find out the text width and the artboard width?