Illustrator Scripting :: CS5 - Change Fill Color Of Selected Path Items
Apr 2, 2013
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'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;
How can I get width that multiple selected items? (Not grouped.)
//---------- source code ---------- var mm = 2.83464566929134 //unit conversion. (point->milimeter) var W = docRef.selection[0].width/mm; alert(W); //---------- source code ----------
I have a collection of circles and rectangles in my document. Is there any way to sort out circles from rectagles using JavaScript? Say i want to make my circles red and the rectangles blue.
I have a very simple javascript for Illustrator that is intended to render all filled objects semi-transparent. It works nicely but for large documents with many objects this takes ages, even beyond the time it would take to do it manually.
I'm wondering if there is any way to improve this script so it works in a reasonable time for large files? I'm running Illustrator CS5 on a Windows 7 64-bit Intel Quadcore i5-2400 @ 3.10 GHz System with 12 GB of RAM and an AMD Radeon HD 6350 graphics. Would upgrading to CS6 significantly improve the speed? CPU load is only at 25%, but I guess javascript cannot be run in multiple threads with the Illustrator engine? Is there another scripting language that would allow me faster processing of that task in illustrator or is my code just poorly optimized?
with (app.activeDocument) { if (pathItems.length > 0) { for (var g = 0 ; g < pathItems.length; g++) { if (pathItems[g].filled == true) { pathItems[g].opacity = 50; } } } }
The first loop grabs the geometries drawn in the current document and rotates it around itself creating duplicates. The second loop is supposed to circumvent more geometries around the newly created geometries.
But instead of creating a radiant pattern, this code builds a tower: for the second loop everytime it grabs the last drawn geometry instead of what is in the "Original"
for NumPaths = 1 to frontDocument.PathItems.count set myPath = frontDocument.PathItems.item(NumPaths) For index = 0 To 30 set newPath = myPath.Duplicate call newPath.translate(100*sin(6.14* index/30),100*cos(6.14* index/30))
Is it possible to script the menu item Object/Path/Outline Stroke?I need to cycle through all the Path items in the document and convert them to Outlines.
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?
When I run the script for an object selection, I want each object to have its color set to the underlying color as if I had used the eyedropper tool. Is this something that can be scripted?
I 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.
I 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) {} } }
I create gradients all the time and i'm wondering if there's a quick way to create a gradient based on the current selected object's fill color. For example: I have selected a box with a fill color of BLUE. I go to the gradient panel and see that what the gradient will be if I click on it (that is usally based on a default gradient WHITE to BLACK, or it comes from the most recent gradiented object I touched). So I click on it and the gradient is activated with the stops being not BLUE. What i want is... if i select a box with a BLUE fill and click on gradient - it will create a gradient with both stops being the same BLUE as the fill color. This would be very convenient because instead of clicking on each stop, shift-eyedropping the the blue color from a duplicated box, it would instantly start with the blue-blue gradient for me to tweak (in the case below for a button i would make the higher stop lighter and lower stop darker).
It's somewhat useful to select an object with a gradient to "copy" that gradient, select a new object, click on the gradient panel and have this new object take on that exact gradient. But most of the time i'm not copying gradients but i'm creating new ones, and it makes more sense for me to create a gradient derived from the fill color.
I'm trying to change the colors of a pathItem corresponding to the string value of several text fields in my document. I've been successful in changing the fill and stroke color of the pathItem, but I can not find any reference in the Illustrator Javascript Guide for accessing additional strokes and/or fills that have been applied to the object in the Appearance panel.
When I open the .AI I noticed that the reference to the visuals is under a %DocumentFiles section: %%DocumentFiles:/Volumes/Storage/Projects/Client/AAA001/visuals/retouc hed.psd %%+/Volumes/Storage/Projects/Client/AAA001/visuals/flattened.jpg
I need to replace "/Volumes/Storage/Projects" with "/Volumes/Projects". (There are some more complex replacements I need, but let's start here.)
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.
I have a question regarding illustrator. Let's say I have a circle with blue fill and red stroke. And I place an image in the illustrator file. Now I want to change the red stroke of my circle to let's say a purple color by sampling the color from the image.
How can I achieve that with a eye dropper tool? Every time when I try to sample a color from the image, the whole circle will change to purple instead of just the stroke? I have tried multiple key combination, shift, alt, ctrl but they all don't work.
I am trying to change the color of all items on and under a specific layer.I have been successful changing the color of specific types of objects (paths), but I need to accommodate all the types on the layer and sub layers.
I can recurse to as many sub layers as I expect, but how do I accommodate the page Items, path Items, group Items, compound Path Items, etc.I was thinking of pushing everything to an array, but I have no experience with arrays...
I managed to write this javascript. It automatically changes the colors from one swatch (byName) to another (byName) in my opened illustrator file. But if this one color doesn't exist as a fill or outline color in a file, I get an error message, because the script can not detect the color. The script stops. I am working on a batch of Illustrator files with 3 colors to change, but some files contain just 1 or 2 of the colors.Is there a command for javascript which says: "Only change the color, if the color appears"?
Here is the script:
var docRef = app.activeDocument; with (docRef) { var findColor = swatches.getByName('TSB Dark Blue').color; var replaceColor = swatches.getByName('TSBDB').color; [code]....
I want to overprint a PMS colors using Applescript. I though if I changed the property of the selected items fill color from (fill overprint:false) to (fill overprint:true) it would work. This doesn't seem to change a thing.
This is the script I am currently using:
script ChangeOverprint tell application "Adobe Illustrator" local docRef
[Code]....
This is the picture of a simple document I created. The elipse has fill overprint:true. The polygon has filr overprint:false. The original value for the property fill overprint was false. I changed it in the script to true. Which the log shows it changed.
I am trying to create a script who could act as an Autocad plot (ie convert each color to black, with a different line weight).
Here is the first script I melted, who create my Black swatch
if ( app.documents.length > 0 ) { var myDoc = app.activeDocument; //add Black swatch var newSwatch = app.activeDocument.swatches.add() var newColor = new GrayColor(); newColor.gray = 100; [Code] .........
And here is the second one, who replace one color by Black (it don't change the text, nor the lineweight yet…
if ( app.documents.length > 0 ) { //test de dialogue function csDialog() { var fabGroup = app.activeDocument.swatchGroups.getByName('Fabrics'); var allFabs = fabGroup.getAllSwatches(); var fabNames = Array();
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 need the finished script to create a rectangle with no fill and a 20% gray stroke to outline each artboard. I dug this up off these boards, which works perfectly except the rectangles created have no fill or stroke. certainly save me a lot of time drawing rectangles on a daily basis.
#target illustrator var docRef = app.activeDocument; var artboardRef = docRef.artboards; for(i=0;i<artboardRef.length;i++){ var top=artboardRef[i].artboardRect[1] ; var left=artboardRef[i].artboardRect[0]; var width=artboardRef[i].artboardRect[2]-artboardRef[i].artboardRect[0]; var height=artboardRef[i].artboardRect[1]-artboardRef[i].artboardRect[3]; var rect = docRef.pathItems.rectangle (top, left, width, height); rect.fillColor = rect.strokeColor = new NoColor(); }
How do I change the default fill color palette in Illustrator CS6? Specifically, I am opening a a new brochure template and the fill and stroke boxes on the left side of the control panel just open with the "no fill" red slash box and the registration mark "bullseye". I would like to have the default color palette load as if it were a new document.
How to go about making it only change the color of text frames on the active layer? In the final script I will hide all other layers so if it could be done by a visible attribute more easily that would work just as well.
Is there a way to export a document @ a different resolution than 72DPI? I know I can set the horizontal/vertical scale to save it at a larger dimension at 72DPI, but I need the file to be actual size and 300DPI.
This is part of a larger process, and I'd prefer to do the entire process from Illustrator, and not have to open the files in Photoshop to change the size/resolution.
Also, is it possible to change the color mode to CMYK or Greyscale for the exported Jpeg?
Exporting to PNG. reference:[URL] We have multiple layers (some off and locked). I'd like to pass all the selected items to the Image Optimization Action as a group instead of optimizing each one. I am using AIMatchingArt Suite to get the selected items, but it points to an array of AIArtHandles..