Illustrator Scripting :: Changing Color Of A Selection To HEX

Sep 6, 2012

I'm new to illustrator scripting (but not to javascript or programming. I have an AI file that has multiple layers. each layer has several items that are supposed to be of same color. I have an array of HEX values.

I would like to loop over all items in a single layer, select them and change their color to some given HEX. Once that works, I will run on all HEX entries in array and save each variation in a separate PNG file.
 
For the first part i wrote some script (see below), but i do not see any change in the file after i run the script. No errors and no change. I run the script once i select all items in a specific layer.
 
My code:

function hexToRgb(hex) {
    var result = /^#?([a-fd]{2})([a-fd]{2})([a-fd]{2})$/i.exec(hex);
    return result ? {
        r: parseInt(result[1], 16),
        g: parseInt(result[2], 16),
        b: parseInt(result[3], 16)

[Code] ......

View 3 Replies


ADVERTISEMENT

Illustrator Scripting :: Changing Selected Text Color With JavaScript

Feb 25, 2013

I want to change my selected text to a different cmyk color using javascript. I have tried and I do not know what is missing or what I am doing wrong.
 
if ( app.documents.length > 0 ) {
newCMYKColor = new CMYKColor();
newCMYKColor.black = 0;

[Code]...

View 4 Replies View Related

Paint.NET :: Changing Color In A Selection?

Jan 18, 2012

I want to take a selection, see all the colors listed within my selected area, and be able to tweak each color to whatever other color I want. I hope that makes sense, if it doesn't say so and I'll see if I can come up with a different description.

View 2 Replies View Related

Photoshop :: Changing A Selection Of An Image Color

Feb 3, 2007

How can I change a selection of an images color. Have an image of a red ladybird (see link below) and want to change it to a different color say a blue or a yellow.

View 3 Replies View Related

Illustrator Scripting :: Changing Opacity Of Text?

Nov 25, 2013

I'm trying to change/access the opacity of a text object (Illustrator CC). In the documents, I found that it's represented by a text frame object, but it doesn't have opacity property. Text range and character attributes don't have it either, so I'm wondering: is there any way of accessing/altering the opacity of a text object using Javascript?

View 5 Replies View Related

Illustrator Scripting :: Resize Selection Around Custom 2D Point

May 7, 2013

I wish to resize a selection around a custom 2D point. I have had a look at the resize function:

#target illustrator
sel = app.activeDocument.selection[0];
var scale = 200;
var scaleAbout = Transformation.TOPLEFT;

[Code] .....

Which works allright but I assume that I need to use the constants defined in the Transformation class? I cannot just input a 2D point to scale around? Would be handy. I have a feeling that I need to use a transformation matrix to do this.

View 4 Replies View Related

Illustrator Scripting :: Select Only Objects Within Selection Marquee

Sep 17, 2012

I am trying to find out if there is a way to select only the objects within a selection marquee? In AutoCAD you can make a selection window from left to right and only those objects entirely within the window are selected. If you window from right to left all objects that are "crossed" or touched by the window are selected. Is there a similar technique in Illustrator?
 
Currently I have to select the objects, then go back and hold the shift key to deselect the object I don't want, or put objects on different layers then lock layers to prevent extra objects getting selected.
 
In AutoCAD, my primary program, you simply draw a selection window, left or right, depending on what your next step would be. No special tools or toggles or thinking ahead, it's just the primary selection process and very intuitive.

View 4 Replies View Related

Illustrator Scripting :: Determining KEY Object In A Selection Via JavaScript

Feb 20, 2013

Is there a way to determine which object in a selection is the key object? For example: draw 10 squares on a layer, select all of them, click on one of the 10 and it becomes the Key Object (heavy border) for things like Distribute Spacing on the Align pallete. I can determine that a particular object is selected via ActiveDocument.Selection.PathItem[n].Selected = true/false. But I can't figure out how to find out if this is the KeyObject. The ultimate goal is to modify the below script so that it uses the KeyObject as the reference and not the object on the bottom-most layer.
 
Here is the Script - from [URL]
 
mySelection = activeDocument.selection;
if (mySelection.length>0){
if (mySelection instanceof Array) {

[Code]....

View 3 Replies View Related

Illustrator Scripting :: How To Get Saved Selection List In JavaScript

Aug 21, 2012

Recently I met a little problem about save selection. I want to get saved selection list so that I can used in javascript. Some useful information about how to get Saved Selection list in javascript!

View 2 Replies View Related

Illustrator Scripting :: Random Delete A Selection Of Items

Aug 25, 2013

I am trying to create a script to specify a percentage of the selected items you want to remove.Here is what I have so far.
 
I still need to work out on the alert prompt and the if statement, but for now, I have the feeling that the selection.length keep changing each time Illustrator delete an object, and I don't know how to make it stick.
  
var selection = app.activeDocument.selection;
//alert prompt dialog for a percentage of deletion
for (var i = 0;  i < selection.length;  i++) {
    if (Math.random < 0.5) { //need to work out the percentage
        alert("yes")
        selection[i].remove();
    }
}

View 7 Replies View Related

Illustrator Scripting :: How To Center Current Selection To Artboard

Feb 17, 2014

how do I center my current selection to the artboard? just like hitting the "horizontal align-center" and "vertical align-center" buttons. I've been searching for the last two hours and before my head hits the keyboard.
 
What I'm struggling with: in my init function i create a new document and then copy all layers from the previous document step by step to the new document and then save it as SVG.
 
// Init
(function(){
          destination = Folder.selectDialog('Select folder for SVG files.', docPath);
          if (!destination){return;}
          holderDoc = app.documents.add();
          stepThroughAndExportLayers(docRef.layers);
}());
 
my problem is that holderDoc = app.documents.add(); always creates a document that is not the same size as my initial document where the layers get copied from.
 
so I want the exact same artboard size as in my initial document.I'm fine with either doing it as fixed values or taking directly the values of the inital doc. i tried this in the segment where I create the new document:
 
// Init
(function(){
  destination = Folder.selectDialog('Select folder for SVG files.', docPath);
  if (!destination){return;}
  holderDoc = app.documents.add();
  holderDoc.artboards[0].artboardRect = [0,0,128,128];
  stepThroughAndExportLayers(docRef.layers);
}());
 
and get this error message: "Error 1200: an Illustrator error occured: 1346458189 ('PARM')

Line: 83
-> holderDoc.artboards[0].artboardRect = [0,0,128,128];"
 
which from what I've read on the web means that illustrator doesnt know what document to pick. but i have called it directly. I do not want to fit the artboard to the images/layer. the artboard should always have a certain size. (for me 128px by 128px)
 
// edit: workaround
(function(){
          destination = Folder.selectDialog('Select folder for SVG files.', docPath);
          if (!destination){return;}
          var activeArtboard = app.activeDocument.artboards[app.activeDocument.artboards.getActiveAr tboardIndex()];
          var ABRect = activeArtboard.artboardRect;
          holderDoc = app.documents.add();
          holderDoc.artboards.add(ABRect);
          holderDoc.artboards.remove(0);
          holderDoc.artboards.setActiveArtboardIndex(0);
          //stepThroughAndExportLayers(docRef.layers);
}());
 
i now added a new artboard to the new document with the same size as the artboard on the initial document.i remove the predefined artboard on the new doc and set the new artboard as active the artboard is now not centered into the window. which lets illustrator place my image with ctrl+c -> ctrl+v somewhere outside the artboard.
 
i now need to align my selection to the center of the artboard. but i cant find any reference on how to center a selection to the artboard.

View 7 Replies View Related

Illustrator Scripting :: Swap Symbol Instance By Changing Its Name?

Aug 11, 2012

I'm trying to swap symbols in situ by changing the 'name' property of the symbol instance.
 
My rudimentary script can find the existing symbol name (for me, that's a small triumph!). The Illustrator document has two symbols in the Symbols panel, 'blue_square' and 'red_circle'. I run the script with an instance of 'blue_square' (and nothing else) on the page, and try to change the name to 'red_circle':
 
var docRef = activeDocument; 
var symbolitem = docRef.symbolItems[0]
 var symbolname = symbolitem.symbol.name; 
var newname = "red_circle";
symbolitem.selected = true; 
// this next line causes the problem:
symbolitem.symbol.name = newname;
 
This causes an error - 'the name is in use'.

View 14 Replies View Related

Illustrator Scripting :: Changing Colors Multiple Files?

Feb 6, 2014

I have about 300+ product labels that are in Illustrator, and some of them have an incorrect rich black color swatch. What I have been doing is going through and changing the color pallette to change them manually. Essentially going to the instance of black and changing them to regular black.
 
Is there any sort of script that can do this? The files are in CMYK.
 
Otherwise I have a lot of monotonous file editing to do.

View 4 Replies View Related

Illustrator Scripting :: How To Make Arbitrarily-shaped Selection Of Objects

Jun 29, 2013

I have a grid of objects—say, tiny squares. I'd like to make arbitrarily-shaped selections of those objects—for instance, select a star-shaped group of the squares. Or a circle-shaped group of the squares. Or use text paths to select letter-shaped groups of the squares.
 
I could imagine a utility that lets me choose an arbitrary shape/path, and then turn that into a selection of objects on the canvas. Is this possible?
 
Right now I'm stuck using the lasso tool to hand-draw shape selections but it's not accurate enough for what I need to do.

View 1 Replies View Related

Illustrator Scripting :: CS5 - Action Or Script To Move Selection To Specified Layer?

May 17, 2013

I have a piece of art on "Layer 1" that i need to shrink and duplicate to "Layer 2". The two layers are always named the same. I'm working in CS5.

View 6 Replies View Related

Illustrator Scripting :: Changing Text From Helvetica To Arial With JavaScript

Mar 11, 2013

I’m working with PDF files in illustrator and whenever the file uses Helvetica I have to change the font to Arial. This gets old when working with hundreds of illustrations. How I would go about changing all text that uses Helvetica bold to Arial bold and Helvetica Roman to Arial?
 
Would I loop through all the text frames and get the value of the font and use that value to change them or is there a more global way to go about this?

View 15 Replies View Related

Illustrator Scripting :: Changing Line Of Text In Multiple AI Files

Apr 5, 2013

I have about 500 files that I need to change one line of text in. Example. File name is XXX 001, the line of text is the file name so it would read XXX 001. XXX 002... etc. up to XXX 500. Is there a way that I could automate it opening, changing this line of text, saving and closing?

View 1 Replies View Related

Illustrator Scripting :: Changing Angle Of Linear Gradient Fill

Feb 4, 2013

Suppose I have an object filled with a linear gradient. This object is the only selected. I just would like to change the angle of the gradient to 25 degrees. So I think I could do:
 
var doc = app.activeDocument
alert(doc.selection[0].fillColor.angle) // the result is the exact angle of the gradient fill of the selected object. Suppose 12 degrees.
 
//now the try to change:
doc.selection[0].fillColor.angle = 25.0
 
No errors are found by the Extended Script Toolkit..BUT...it does not change anything. As Illustrator reference manual does not say this property is read only, I think I could write.

View 2 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Changing Color Of Selection Sets?

Jul 27, 2013

I need to create a command which could change a color of an allready existing selection set when activated. For example i have a command which creates a cube, where each specific group of lines were added to different selection sets. how can i recall any created selection set by its name and change its color?

View 9 Replies View Related

Illustrator :: In Color Picker / Selection In Color Palette Is Different Than Preview

Oct 2, 2012

Working in Illustrator CS5 on a Mac. When choosing a color in the palette, the preview showing up is different than what is in the palette. If I hit "OK" the actual color chosen is the one in the palette, not the preview window... Including some pics for reference. In my 10+ years of using Illustrator, i have never seen this.I am using a Dell monitor on a mac... not sure if that would make a difference.

View 3 Replies View Related

Illustrator :: Change Layer Selection Color From Black To Color?

Jan 8, 2014

Somehow I've turned off the color selection so that I don't have a color when I select a part of a drawing on a layer. The drawing area stays black whether I have selected it or not and I don't know how to turn back on the color.
 
how I can turn on the color again so that when I select a line it changes from black to red or magenta or whatever?

View 3 Replies View Related

Illustrator Scripting :: Apply Current Fill Color To Stroke Then Adjust That Stroke Color's Build?

Apr 9, 2013

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.

View 13 Replies View Related

Illustrator Scripting :: Color Change To Various Types?

Feb 6, 2013

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...

View 3 Replies View Related

Illustrator Scripting :: Typename Of The Filled Color?

Jul 18, 2012

I am trying to use the property "typename" with the fillcolor. I am using following statement:
 
grp.compoundPathItems.index(j+1).pathItems.index(0).fillColor.typenam e
 
It'll give error i.e. access of undefined property typename.
 
Is there any way of finding the typename of fillcolor?
 
Actually, I want to get the type of fillcolor used in pathitem, i.e. is it "GradientColor", "PatternColor" or "SpotColor".

View 4 Replies View Related

Illustrator Scripting :: Eye Dropper Or Color Sampling?

May 2, 2012

I'm trying to make a script to transform shape by a value of below object.

(look sample image below)

And I'd like to know how to sample color from gradient-mesh or bitmap photo.
 
 Does illustrator script have eyedropper or color sampling tool?

View 3 Replies View Related

Illustrator Scripting :: Color Change Command In JavaScript

Feb 4, 2013

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]....

View 2 Replies View Related

Illustrator Scripting :: Syntax To Check Pantone Color?

Aug 16, 2013

Syntax to check pantone color

eg (list.fillColor=="[CMYKColor]")

like that how to find pantone color and how to get the name of the pantone used

View 3 Replies View Related

Illustrator Scripting :: Raster-item Didn't Get Color

Mar 22, 2012

I 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 Related

Illustrator Scripting :: Change Overprint Of Color With Applescript

May 4, 2012

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.

View 1 Replies View Related

Illustrator Scripting :: How To Fill Gradient Color In Textframe

Sep 3, 2013

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.

View 6 Replies View Related

Illustrator Scripting :: How To Show The Color Picker Dialog

Feb 22, 2014

how to show the color picker dialog in Illustrator programmatically?

In photoshop that's really easy, just:
 
app.showColorPicker(true);
 
In Illustrator I couldn't find any reference to such a method or other possibility to show the dialog programmatically, that you would normally get when double clicking on the fill color square within Illustrator.
 
Is that possible by using app.executeMenuCommand or some other method?
 
I am writing a script that opens the color picker dialog in reaction to a click on a button. I want to be able to get the chosen color and use it within the script.

View 21 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved