Changing the color of a selection to HEX

Hi guys,
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.
Can you please advise what am i doing wrong?
Thanks in advance!
My code:
function hexToRgb(hex) {
    var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
    return result ? {
        r: parseInt(result[1], 16),
        g: parseInt(result[2], 16),
        b: parseInt(result[3], 16)
    } : null;
var fillRGBColor = function (pathItem, r, g, b){
    pathItem.fillColor.red = r;
    pathItem.fillColor.green = g;
    pathItem.fillColor.blue = b;
var fillHexColor = function (pathItems, hex){
    var rgb = hexToRgb(hex);
    alert(rgb.r +","+rgb.g+","+rgb.b);
    fillRGBColor(pathItems, rgb.r, rgb.g, rgb.b);
// check if a document is open in Illustrator.
if( app.documents.length > 0)
          mySelection = app.activeDocument.selection;
          if (mySelection.length > 0)  {
             for (var i=0; i<mySelection.length; i++) {
                  var currentObject = mySelection[i]; 
                  if(currentObject.typename != "CompoundPathItem" &&  
                                                            currentObject.typename != "GroupItem")  {
                         fillHexColor(currentObject, '#8F623B');
          } else {
                         alert("Nothing is selected.");
} else {
          alert("No document Open.");

Yup!
my objects were in CMYK mode and not RGB. i changed the handling and everything started working fine.
I have a different question now - how can i color TextFrame objects?
I have a layer with some text on it and i want to generate a bunch of PNG files from that layer with text color changes.
I see that the selected element is of type TextFrame, but it does not have a fillColor attribute.
what controls text color?
thanks in advance!

Similar Messages

  • KdeGraphics-Okular - How to change the color of Text Selection tool

    Hello All
    I'm trying to know how to change/fix the color of the Text Selection Tool (Ctrl + 4). Because when I highlight the text, it's only one color (Dark Blue) that make me could not read clear.
    ---- My OS Configuration
    OS : Arch
    DE: LXDE
    WM: OpenBox

    The highlight color is determined by the system-wide color scheme that you're using. There's no way to change it only for okular.

  • Can you change the color of a row in a SUD

    Is it possible to change the color in a selected row in a SUD? I have multiple tables in my SUD were the user can select multiple rows from each table. The problem is that when the user selects rows in another table the last one selected in the previous table is not hi-lighted. I thought that if I change the color of the row when selected the user can see all the selections once he/she goes to another table.
    Thanks,
    AJL

    Hi AJL,
    There is no way to color rows of the table control in a SUDialog. You could consider using the ActiveX container control and using the Microsoft ActiveX table control, which might have that functionality. Note though, that then you need to either ensure that control is always on all your client machines or make provisions for it to be installed/registered.
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • Can I change the color properties of an indicator in a cluster?

    I have a cluster that has three boolean indicators in it. I would like to have an initial state (color) they are in at the beginning of my test. Is there a way to set color properties of a boolean indicator that is inside a cluster? Thanks in advance for any help.
    Troy
    Solved!
    Go to Solution.

    Hi Troy,
    I just created a simple application in which I can change the color of one of my boolean indicators on the fly. You'll find it attached to this message.
    It's quite simple to do:
    When you've created both clusters in the front panel, right click on the indicator you want to change the color of.
    Select the option "Create"
    And than select the option "Property Node"
    Now you can ad whatever property to the boolean indicator you want.
    Hope this will help you any further with your program!
    Best regards,
    Peter S
    Attachments:
    change boolean color in cluster.vi ‏9 KB

  • Can you change the color of selected text in word?

    I use Word 2010, and when I select text it is always blue, is there a way to change the color?

    I use Word 2010, and when I select text it is always blue, is there a way to change the color?
    My earlier posting was an error.
    I apologize.
    You seem to be saying that the default colour for text is blue.
    You need to change:-
    Normal.dotm
     - to change the default colour of text.
    In order to change the default colour of text take the following steps (that were tested on Windows 7 and Office 2007 - the process should be
    similar, if not identical, for yourself):-
    1. Open a new blank document (this should
    have the default text as blue).
    Save that document with a new name for example:-
    c:\word\testing_aug_25_2014_2
    2. In the above document:-
    Insert tab
    Text group
    Click on the drop down arrow to the lower right of:-
    Quick Parts
     - then click on:-
    Field . . .
    The:-
    Field
     - window should open.
    3. In the:-
    Field
     - window in the field called:-
    Field names:
     - scroll down to:-
    Template
     - and click on that option so that it's highlighted in blue.
    Now, towards the top right hand corner of the same window, click in the box called:-
    Add path to file name
     - so that it has a tick (check mark) in that box.
    Click:-
    OK
    The file name of the template should now be inserted into your document.
    On my machine this was:-
    C:\Users\user_name\AppData\Roaming\Microsoft\Templates\Normal.dotm
    The above path might be different for you.
    4. I saved my document at this point.
    5. Now open the file called:-
    C:\Users\user_name\AppData\Roaming\Microsoft\Templates\Normal.dotm
    A document should open on your screen (still with blue text) and with:-
    Normal.dotm
    - in the middle of the Title Bar at the top of the screen.
    Highlight all of the text in the document so that it's (for example) black.
    Save the file.
    6. Close all open documents in WORD and
    close WORD itself.
    7. Now open a new document and its default
    text should be set to the colour that you applied at step 5. above (I used black at that point).
    Does that resolve your problem?

  • Changing the color of the column in a JTable based on the selection (mouse)

    Hi,
    I want to change the color of all the cells in a column based on the mouse clicked event.
    I have managed to select the entire column. And, even, I have found a working example in the internet. But I don't understand why in my case it doesn't work.
    This is the code (an inner class for a TableCellRenderer):
    class MCTableCellRenderer extends JLabel implements TableCellRenderer {
              private static final long serialVersionUID = 1L;
              @Override
              public Component getTableCellRendererComponent(JTable table,
                        Object value, boolean isSelected, boolean hasFocus, int row,
                        int column) {
                   setFont(table.getFont());
                   if(value instanceof Double){
                        setHorizontalAlignment(SwingConstants.RIGHT);
                        DecimalFormat numberFormat = (DecimalFormat) NumberFormat.getInstance();
                        numberFormat.applyPattern("#######.#");
                        String val = numberFormat.format(value);
                        setText(val);
                   if(isSelected){
                        setBackground(Color.RED);
                        System.out.println("is selected");
                   else{
                        setBackground(Color.BLACK);
                        System.out.println("is not selected");
                   return this;
        }I have set opacity to true for the contentPane, but without any result.
    Any advice will be very apreciated.

    Problem solved.
    My Renderer should have extended the abstract class DefaultTableCellRenderer.
    class MCTableCellRenderer extends DefaultTableCellRenderer {

  • Hello. I am trying to change the colors on my ical. I have been able to select a calendar group, click "get info" and then "other" in the color options and which point a a lot of color options are available. HOWEVER, I can't seem to select the color.

    Hello. I am trying to change the colors on my ical. I have been able to select a calendar group, click "get info" and then "other" in the color options and which point a a lot of color options are available. HOWEVER, I can't seem to select the color. I click on a new color and press enter and nothing happens...not sure what I am doing wrong.

    What do you currently see?
    Can you attach a screenshot?
    *http://en.wikipedia.org/wiki/Screenshot
    *https://support.mozilla.org/kb/how-do-i-create-screenshot-my-problem
    Use a compressed image type like PNG or JPG to save the screenshot.
    Do you have the menu bar?
    *Press the F10 key or tap the Alt key to bring up the hidden Menu bar.
    Do you have any toolbars visible at all?
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    Make sure that you do not run Firefox in full screen mode (press F11 or Fn + F11 to toggle; Mac: Command+Shift+F).
    *https://support.mozilla.org/kb/how-to-use-full-screen
    You can check for problems caused by a corrupted localstore.rdf file.
    *http://kb.mozillazine.org/Corrupt_localstore.rdf

  • When I visit a site the color of the link seldom changes to the color I have selected. also even when it does change, it reverts to the unvisited color in a day or so.

    When I visit a site the color of the link seldom changes to the color I have selected. Also even when it does change, it reverts to the unvisited color in a day or so. The history is set to over 300 days and everything is there as far as I can tell.

    Does this problem affect all sites, or only some? Try going to a Google search results page and click a few links. Then, come back a day later and see if they are still visited.
    It may be that the links that get reset are coming from a frameset. Firefox only remembers history from framesets temporarily, which affects sites that use them. (An example would be the craigslist forums)

  • I am having a problem changing a color in a selected area. Using the Quick Selection tool I am able to select the area I wish to change. Using the Brush tool, color, color mode and click drag in my selected area, nothing happens, no color changes.   I hav

    I am having a problem changing a color in a selected area. Using the Quick Selection tool I am able to select the area I wish to change. Using the Brush tool, color, color mode and click drag in my selected area, nothing happens, no color changes. I have viewed some videos and read numerous articles but haven't found the one to help me. Please point me in the best direction. Thank you Vincent TC

    For the sake of clarity and to save people time, Todd is asking about the behaviour of the Patch tool when using it to repair the area next to the young lad's head.  Todd gets a blurred dark tone pretty much regardless of the options he uses.
    IMO that's what I would expect to happen because of the close proximity of the other image elements i.e. the lad's neck and the strong lines of his shirt.  I would not choose to use the Patch tool in this situation.  Content Aware Fill makes a better stab at it. 

  • Can't change the color of a JButton when selected

    I'm unable to change the color of a JButton with the following code:
    UIManager.put("Button.select", Color.cyan);
    SwingUtilities.updateComponentTreeUI(this);
    This works just fine with 1.2.2 but when I use 1.3.1 the JButton turns gray instead of cyan. What changed between these versions?

    Hello,
    I tested the following code and it works on JDK1.3.1:
    import java.awt.*;
    import javax.swing.*;
    public class RedButton {
    public static void main(String args[]) {
    JFrame frame = new JFrame("Red");
    frame.setDefaultCloseOperation(
    JFrame.EXIT_ON_CLOSE);
    Container c = frame.getContentPane();
    JButton defaultColor =
    new JButton("Default Colors");
    c.add(defaultColor, BorderLayout.NORTH);
    UIManager.put("Button.background",
    Color.RED);
    JButton red =
    new JButton("Red");
    c.add(red, BorderLayout.SOUTH);
    frame.setSize(200, 100);
    frame.show();
    You also can use one of the following properties, instead of background:
    Button.background
    Button.border
    Button.darkShadow
    Button.focusInputMap
    Buton.font
    Button.foreground
    Button.highlight
    Button.light
    Button.margin
    Button.shadow
    Button.textIconGap
    Button.textShiftOffset
    So, as you can see, there is no select Option.

  • Changed the color of the selected text

    I changed the color of the selected text in Photoshop CS6, from black (background) & white (text) to different colors. I want to know how I did it.

    Selecting tends to invert the text. Use Ctrl/Cmd h while in Text edit mode to hide the selection.

  • I am unable to change the color of text in an email I replay to or compose. I am on 31.6.0 release of Thunderbird.

    When I receive, reply or compose email. I no longer am able to see or change the color of text. I select to change the text from black to Red (or any other color) and the text just stays black, The color seletor box will show the last select color, but never actually changes the text color in an email. Also in received email, when the sender has indicated their replies to me are in another color, All the text only appears as black. I never had this problem in the past, not sure what has happened. I did restart Thunderbird with add-ons disabled and this did not change the problem.

    Hello, maybe the question need to move by a moderator to thunderbird support ?
    https://support.mozilla.org/en-US/questions/thunderbird?owner=all
    thank you
    [moderator note: question thread has been moved from Firefox queue to Thunderbird queue]

  • I need to change the color of the font in my Bookmark Toolbar. Unable to read all bookmarks.

    No longer have a question about editing the Bookmarks Toolbar. I may be dense, but I have not discovered how I may change the text (font) color when using View, Bookmarks, Custom. I see the capability to choose to use text and image, but not to change the color of the text. The ability to "bold" the text would probably be sufficient. I will revisit the Getting Started page and select other background colors to try and alleviate the problem. Persona or thema colors conflict with black text (for my older eyes - I have a vision problem.).

    You can make such a change with code in userChrome.css
    Add code to [http://kb.mozillazine.org/UserChrome.css userChrome.css] below the @namespace line.<br />
    See http://kb.mozillazine.org/Editing_configuration#How_to_edit_configuration_files
    <pre><nowiki>@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* only needed once */
    #personal-bookmarks .toolbarbutton-text {
    color: black !important;
    background-color: -moz-dialog !important;
    font-size: 11pt !important;
    font-weight: bold;
    </nowiki></pre>
    You can adjust the values or leave out things that you do not want to change.

  • How to change the color in "blocks" effect

    Hi,
    I've got a problem with Motion.
    I use a "behaviour" effect on my text that is called "blocks".
    When I set parameters to default, I see a blue effect with some red blocks in backgroud.
    I want to turn this effect into a green effect.
    The problem is that when I change the color into green, there is still a strange orange color on some blocks.
    I've added all the color parameters (face, shadow...)that I thought it could be due to but nothing changes. I still have this strange color on some blocks.
    The strangest thing is that it sometimes becomes ok when I make the changes but when I save and re-open my file in FCP or Motion, it isn't ok.
    Has anyone already used this effect and seen that problem?
    Thanks for your help...
    Sand
      Mac OS X (10.4)  
      Mac OS X (10.4)  

    Text behaviors work by sequencing the Text's parameters.
    Try changing the color of your text's outline.
    Select the Text tab in the Inspector
    Go to the Style sub tab
    change the Outline color to green
    Hope that helps.

  • Is it possible to change the color of the text in one specific field?

    If I want to make someone's mobile number show up as the primary contact, is it possible to make the text for that number a different color or make it bold? I can't seem to find a way to do it.
    Thanks.

    Make a Shape > Inspector > Graphic > Tinted Image Fill > Scale to fit > browse to image > click on the color patch to change the color to what you want
    or
    Drag in an image > overlay it with a Shape > select the color for the shape and change its Opacity
    Shapes may have Gradient and Advanced Gradient (multiple colors) fills both linear and radial. Both are in the Graphic Inspector as is Opacity.
    Peter

Maybe you are looking for

  • My apple tv seems to have hung up during the latest software update - what should I do now?

    my apple tv seems to have hung up during the latest software update - what should I do now? I have not turned it off but it has been stuck in the same spot for 30 minutes now and I'm not sure what to do next since the screen says to NOT turn it off u

  • Newbie's first Spry site

    Although I've designed web sites, this is the first time I've tried programming. Cribbing from other people's code; reading the forums etc has all been very usefule (and inspiring). However, after wrestling with CSS, XML and Spry, I need some help. S

  • Just upgraded to 10.6.3 and now will not recognise old library

    When I upgraded to 10.6.3, I got a message asking my to create a new Library. OK I thought Apple knows what it is doing. So I created a new Library - itunes1 and now when opening itunes it is itunes1 and empty of all music, podcasts and playlists. Ho

  • Can somebody please export a MIDI file for me?

    Hey! I am a garageband user and upgrading soon to Logic, but I extremely need this file in MIDI. Can anybody open my garageband project with logic and export a midi for me? I would be very-very thankful for that! Janek http://www.upload.ee/files/3660

  • G61 Notebook pc with Windows 7 32 bit OS Drive "E" and "F" disappeared

    after several years of no problems, I can only find drives "C" and "D" (recovery)  I don't know where "E" and "F" went. I cannot play a CD or DVD.  When I checked the system information it said there was an error in these drives and they have been di