Illustrator Scripting :: How To Read Swatch Used For Fill Color Of A Page Item
Mar 21, 2012Is there a way to read the swatch used for fill color of a page item?
I can read the fill color but I can't read if the color is a global swatch.
Is there a way to read the swatch used for fill color of a page item?
I can read the fill color but I can't read if the color is a global swatch.
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;
[Code]....
Does name property of a page item appear anywhere in the user interface in Illustratpr CS6? I thought it would be the name you assign to it in the Layers palette, but it does not appear to be.
View 2 Replies View RelatedI am working on a script that performs a series of things on all of the artwork in a document. At one point, it needs to compare the fill color of every item to a sample color. The problem is, the artwork is a collection of compound path items and path items. When I look for pathItems[x]. fillColor, it works fine. When I look for compoundPathItem[x].fillColor, it comes back undefined. So, I've moved to looking at page items, but I seem to be unable to get to the internals on the page items. If I have a compound path item, how would I address its properties from its parent page item? I tried:
pageItem[x].compoundPathItem.pathItems[0].fillColor,
pageItems[x].fillColor, &
pageItems[x].compoundPathItem.fillColor.
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.
View 1 Replies View RelatedI'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;
[Code] ......
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?
View 7 Replies View RelatedI 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?
View 7 Replies View RelatedI have written a small application in .NET that gives color to Illustrator files.I have a layer with 100 color items (paths with a fillcolor). Each one has a unique name. Through that name my program looks them up, takes the fill color and applies that color to another path.Recently there was a change in Design, the drawings that I had to provide of a Fillcolor were no no longer pathitems but rasteritems (imported from photoshop). I thought ok no problem instead of setting the Fillcolor property I'll use the Colorize method on the rasteritems. It worked fine but now and then I came across a situation where raster-item didn't get the color. After digging in to it I saw that it was because some colors are Pantone colors and the colorize method on rasteritems only takes RGBColor or CMYKcolor objects. How to do it with the pantone colors?
View 1 Replies View RelatedI have a number of art items on a document, some of them are filled with spot colors and some of them are with process color.Is there any method by which I can find out which color type(spot or process) is applied to the selected art item?
View 4 Replies View RelatedI am working with scripting in Ai, fill gradient color in TextFrame. I search in this forum but the other topics fill color to path or line. For now, I can make a gradient color, but I don't know how to apply it to textframe.
View 6 Replies View RelatedSelect same fill color with java script and stroke color tool.
View 1 Replies View RelatedI have a script that will select text Frames, but I have come into a situation where I need to exclude any text frames that do not have a fill color. I do not see a filled Boolean property for character attributes or text Frames.
This is what I used to select all text on all visible and unlocked layers. I dont see a way to exclude textframes that have no fillcolor.
if (app.documents.length > 0 ) {
var doc = app.activeDocument;
var numTextFrames = 0;
for ( i = 0; i < doc.textFrames.length; i++ ) {
try {
textArtRange = doc.textFrames[i];
textArtRange.selected = true;
} catch (e) {} } }
If i want select objects that same fill color in document, I can use 'select - same - Fill color' function in Illustrator.
It's so fast. below 1 second.
But, If i want make it in Javascript, I can't do it like fast.
for(i=0; i<activeDocument.pathItems.length; i++){...}
If document have 10,000 objects, above script can't finish in even 60 seconds.
How Illustrator can traversal fast?
Is there something other way?
I'm trying to create a script in CS5 mac os10.6.8 that will change the fill color of selected pathItems. I need a simple script that will change a selected pathItem to cmyk values 2,3,15,0. I will then select this script and implement the action in a batch of 600 files.
I wish this process could be recorded as an action but when I record the action "add new swatch" I have to manually input the cmyk values, which will take forever for a batch of over 600 files.
I have been trying to mess with and target "tints" via javascript but either I am not understanding something or it cant be targeted as I had hoped, so I am looking for direction and guidance. I have a spot color assigned in the color swatches palette, and have drawn a few boxes on the page using this spot swatch. I then try to alter the tint using JS code.
sel[i].tint = // whatever number
alert(sel[i].tint) // This alerts fine
The alert shows a change taking place but it never gets applied to the item, the actual item never gets changed. I know things are properly targeted as I can change other attributes fine. When I look in the JS documentation it just shows for when creating a new spot, not for ones that already exist on items, I cant seem to find an example otherwise.
Can tint be adjusted for items on the page that have a spot color applied?
I'm trying to figure out a way to automate a simple, yet repetative process I do countless times a day. Ideally, I'd like to tie it to a keystroke to speed up my workflow.
I work on line art and colorways for footwear, so the way I'm coloring these shapes and strokes break apart the different materials and pieces of the shoe.
While coloring line art, I work with Pantone spot colors as fills for closed path objects. I then have to manually apply that same color to the stroke, set the stroke to 0.5px weight, convert that spot stroke color to CMYK, and add 15% to the K value.
I found some code in an older post for applying the actively selected object's fill color to the stroke, but I'm having but I'm having trouble with the next step of figuring out how to take that spot stroke color and convert it to a CMYK build that I can then add 15% black to. Is this something that's even possible? I've spent about an hour playing with the script and have only had luck matching the fill color or turning the stroke white.
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've been experimenting with:
app.activeDocument.textFrames[0].characters[3].characterAttributes.fil lColor.typename;
// Returns SpotColor
But I can't figure out how to get the swatch name of the character this way?
I've just created a map with various county boundaries. I now need to fill in the counties with various shades of gray, with no two neighboring counties sharing the same shade. I've been going about it in a sort of trial and error fashion, but I can't ever seem to get it right. Is there a way that Photoshop could possibly fill it in for me? Sort of an auto-swatch application thing?
View 2 Replies View RelatedI'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 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.
how to get the page count of a multi page PDF file? I know you can then open each page using the PDFFileOptions (pagetoopen). But I need to know up front how many pages there are to loop thru to open each page and process each page.
View 8 Replies View Relatedwhen I select a swatch for an object the default was to apply it to the fill color. I don't know why but it started applying a swatch when selected to the outline/stroke instead. How can I change the default application of swatches back to the fill color?
View 4 Replies View RelatedWhen writting scripts to Photoshop I can use the app.runMenuItem() method to acess commands in the menus. For example: app.runMenuItem (charIDToTypeID("ZoomIn")) will run the Zoom In command.
Does Illustrator have any such method (or accepts anything like action description) to enable us to acess it´s menu items? For example acess Expand comnand, or Object > Live Paint > Make..
In CS5, how do I fill a mitered border (a rectangle with 45 degree angles at each end) on a quilt with a stripe swatch and have all 4 borders match? When I fill from the swatch, the stripe is jumbled - the lines are not in the same order as in the swatch.
View 11 Replies View Related