How to set fill, stroke & color to a group

First of all, I must say I'm a complete beginner in Javascript so please have patience with me.
What I'm trying to do is to set a lot of groups to specific fill, stroke & color using a function.
var docRef = app.activeDocument;
var Reg = docRef.swatches["[Registration]"].color;
var mm = 2.834645;
var lineWidth=0.12*mm;
group1.stroked=true;
group1.strokeColor = Reg;
group1.filled = false;
group1.strokeWidth = lineWidth;
This works, but I have to this for every group and there are lots of them.
So I tried to make a function:
function setAttributes(temp)
temp.stroked=true;
temp.strokeColor = Reg;
temp.filled = false;
temp.strokeWidth = lineWidth;
And then call that function for each group:
setAttributes(group1);
setAttributes(group2);
setAttributes(group3);
etc.
Of course, this doesn't work since I have incredible programming skills
Please help.
Thanks!

The script as it is should ONLY change the path items that are in your 'first level' of group items… If you need to change the properties of path items outside of the groups then you could add another loop… Heres one way you add the extra loop:
var docRef = app.activeDocument;
// Set variable to your color
var reg = docRef.swatches.getByName("[Registration]");
// Set a variable to the document path items collection
var pathList = docRef.pathItems;
// Loop through this list of objects
for (var h = 0; h < pathList.length; h++)     {
     // Change the property values
     pathList[h].filled = false;
     pathList[h].stroked = true;
     pathList[h].strokeColor = reg.color;
     pathList[h].strokeWidth = 2;
// Set a variable to the document groups collection
var groupList = docRef.groupItems;
// Loop through this list of objects
for (var i = 0; i < groupList.length; i++)     {
     // Re-use variable for the groups path items collection
     pathList = groupList[i].pathItems;
     // Loop through this list of objects
     for (var j = 0; j < pathList.length; j++)     {
          // Change the property values
          pathList[j].filled = false;
          pathList[j].stroked = true;
          pathList[j].strokeColor = reg.color;
          pathList[j].strokeWidth = 2;
app.redraw();

Similar Messages

  • Automatically set the stroke color as fill color

    Hello all,
    I have a file with two squares with red and blue fill colors respectively and transparent surrounding strokes. I'm trying to find a way to automatically set the stroke color of each square to the respective fill color.
    Is there an Illustrator script somewhere that would achieve that? I am not aware of an internal Illustrator command for this purpose.
    Thank you

    I'm not a scripting guy at all, but getting an object's fill color and applying it elsewhere sounds like it should be scriptable. You should post the question in the AI Scripting Forum.
    The hitch I see here is your assertion that your objects have "transparent surrounding strokes." I could be wrong, but I believe there is actually no such thing in Illustrator. Through some simple experimenting, I conclude that an object's stroke set to "no color" by choosing the blank swatch actually becomes a stroke of undetermined, or perhaps zero, weight.
    Take an object with a stroke color and weight and set its stroke to no color. The weight goes away as well. One can't exist without the other, and vice-versa, with repect to stroke weight and color. Now enter a weight for that colorless stroke, and it again receives color; defaulting to black regardless of what it may have been previously.
    Similarly, if you assign a color where there is no weight, a 1-point weight appears by default.
    I'm not sure how/if that plays into your plans, but I just thought I'd ramble on about it here in case it's something you hadn't considered.

  • How to set dash line color(two colors)?

    hello all:
    Does anyone know how to set dash line color in java?
    I only know how to set line color with a single color.
    g2.setColor(Color.black);
    g2.setStroke(dashed);
    g2.draw(new Rectangle2D.Double(50, 50, 200,100));
    what I need to implement is two colors interleave on the dash line.
    so that dash line looks like this:
    ==== ====
    red white red white
    thank you for any comments.
    -Daniel.

    create 2 strokes, space them appropriately, draw the rectangle twice.

  • How to set a HTML color to a control button

    How to set a fixed color to a disabled button?
    I have a boolean button which has 3 status: on, off and disabled. I don't like the 'grayed and disabled' option. I will use red for off, green for on, and white gray (foreground color) for the disabled status. The HTML color code is BDBDBD. I tried to send the hex number 'BDBDBD' to the button property node 'color[4]' but was told that I was wiring to the wrong type of terminal.
    Could any one post a sample code of how to construct the structure of 'color[4]' using a RRGGBB number?
    Thanks,
    Ryan

    What exectly do you want and do you see.
    If I run the code you have in LabVIEW 9.0, I get the following result after running.
    For convenience I have shown the second color array you set as color indicators:
    Note that you use grey as the colors for True and False
    Here I have set made the colors more distinct:
    Ton
    Message Edited by TCPlomp on 07-10-2009 08:00 AM
    Message Edited by TCPlomp on 07-10-2009 08:01 AM
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!
    Attachments:
    ButtonColor_FP.png ‏17 KB
    ButtonColorMoreColor_FP.png ‏18 KB

  • How 2 set the background color in j2me

    Can any body tell me how to set the background color to midlet.??

    if you are using Screen then you can call its setBackColor()
    or if you are using Canvas then you can call
    g.setColor(r,g,b);
    g.fillRect(0,0,getWidth,getHieght);
    where g is the Graphics instance of Canvas,for further information consult documentation

  • How to change Object Stroke Color and fill Color?

    Hi to all
    i need to change fillcolor & stroke color of Object
    here i wrote code that tried but it is not
    myDoc = app.activeDocument;
    var dd = myDoc.colors.add({name:"PANTONE Black C", model:ColorModel.spot, colorValue:[0, 13, 49, 98]});
    app.findObjectPreferences= NothingEnum.NOTHING;
      app.changeObjectPreferences = NothingEnum.NOTHING;
      app.findObjectPreferences.fillColor = "Black";
      var myI1 = myDoc.findObject();   
       app.changeObjectPreferences.fillColor = "PANTONE Black C // here error throwing
        app.changeObject ();
    app.findObjectPreferences= NothingEnum.NOTHING;
      app.changeObjectPreferences = NothingEnum.NOTHING;
      app.findObjectPreferences.strokeColor = "Black";
      var myI2 = myDoc.findObject();   
       app.changeObjectPreferences.strokeColor = "PANTONE Black C // here error throwing
        app.changeObject ();
    Error is :  Invalid value for set property 'fillcolor' ,Expected Swatch, String or NothingEnum enumerator, but received "PANTONE Black C";
    pls help me...
    Thanks
    Thangaraj

    Hi scriptor,
    how to create find change query for object search
    pls tell me with script.
    here i attached one jpg file screen shot to understand my need
    Thanks
    Thangaraj

  • How to set image background color ?

    Hi All,
    In my project i have image,and if image have black spot or any unwanted spot then i will select that area and say clear it then it will remove that spot and set color of that area similar to area around that spot.
    I have written code for getting pixel color of selected area in image like this
    BufferedImage old_image = ImageIO.read(new File(myFile));
    int[] pixels = new_image.getRGB(0, 0,new_image.getWidth(), new_image.getHeight(),null, 0, new_image.getWidth());
    for (int i = 0; i < pixels.length; i++) {
    Color pixelColor = new Color(pixels);
    System.out.println("RGB ::"+pixelColor.getRGB());
    RGB returning negative value;
    Please tell me correct way how can i do this.
    It's very urgent.
    Thanks in advance.
    Thanks
    AP.

    i found the browser fill button.  Now how do I fill the browser fill with an image?

  • In acrobat 9 pro how do you fill a color in a picture?

    Hello Everyone,
    Does anyone know how to fill a color in a picture using Adobe acrobat 9 Pro. Lets say you have a picture in PDF format, that has a picture of a billboard, and that billboard is not really straight, kinda different shape, how could someone leave it in as a PDF and color the bilboard?
    Any help would be great!

    Actually Graffiti it might be able to be done via 'touchup tool' without creating a new PDF. Assuming of course a photo editor like Photoshop is present.
    To the OP: Acrobat is intended as final destination format and not really suitable for editing (although minor changes can be made with the full Acrobat product). It's always best to do the changes to the original document and then make a new PDF making sure you acknowledge proper version control procedures. Changing the PDF means that you now have a PDF that doesn't match the original document.

  • How to set foreground gradent color to label???

    using this i can set background gradentcolor to label. But how to set foreground gradentcolor to label???
    JLabel compname = new JLabel("ARDENT TECHNOLOGIES INC")
              protected void paintComponent(Graphics g)
                { int width = getWidth();
                int height = getHeight();
                GradientPaint paint = new GradientPaint(0, 0,  Color.blue, width, height, Color.green);
                Graphics2D g2d =(Graphics2D)g;
                g2d.setPaint(paint);
                g2d.fillRect(0, 0, width,height);           
                super.paintComponent(g); } };
                compname.setOpaque( false );Thanks in advance
    raja

    reply #3 looks interesting
    http://forum.java.sun.com/thread.jspa?forumID=257&threadID=481290

  • How to set a background color to view

    Hi All,
              i creared a view with 2 textboxes and a button.These elements are in TransparentContainer.I set the background color to the TransparentContainer.By setting color to the TransparentContainer it is comming at the center and the 4 sides of it is displaying in the normal background color of the browser
    i didnt find any color options for the view called RootUIElementContainer.the width and height of the view are setted to the browser means 1024*768.
    Just like sap editor which we get by the link https://www.sdn.sap.com i want to get my view .....
    I want to set color to this RootUIElementContainer element which effect the whole view...not the containers or groups which i add under this RootUIElementContainer
    Regards
    Padma N

    hi Padma,
    For changing the background colour you will have to make the change in the theme.
    You can download the theme editor plugin for eclipse from SDN. With this plugin, you can make changes to the default themes , save as a new theme
    Or if you are using portal, then goto system administrator, theme editor, select SAP Streamline and change the color in Screen areas -> application, then save the theme with different name.
    Best regards,
    Sangeeta

  • How to set the Background Color of a Text Field in a Tabular Report.

    Hello,
    I tried to set the Background Color of a Text Field in a Tabular Report.
    But I was not able to change this colur.
    In the report attributes --> column attributes
    I tried already:
    1. Column Formating -- >CSS Style (bgcolor: red)
    2. Tabular Form Element --> Element Attributes (bgcolor: red)
    but nothing worked.
    Can anybody help me?
    I Use Oracle Apex 2.2.1 on 10gR2
    thank you in advance.
    Oliver

    in "Report Attributes" select the column to move to the "Column Attributes" page. In the "Element Attributes" field under the "Tabular Form Element" region enter
    style="background-color:red;"
    I will also check if there is a way to do this via the template and post here again
    edit:
    in your template definition, above the template, enter the following:
    < STYLE TYPE="text/css" >
    .class INPUT {background-color:red;}
    < /STYLE >
    (remove the spaces after the < and before the >)
    change "class" to the class that the template is calling
    (I'm using theme 9, the table has: class="t9GCCReportsStyle1" so I would enter t9GCCReportsStyle1)
    A side-effect of using this second version is that ALL input types will have a red background color--checkboxes, input boxes, etc.
    Message was edited by:
    TheJosh

  • How to set the Default Dashboard for a Group

    Hello,
    we have, in our project, two groups defined in the dashboard; How can we set the Default Dashboard for each Group?
    Actually every user of both groups at logon views the "my dashboard" page.
    Thank you

    hi
    check this http://obiee101.blogspot.com/2008/06/obiee-directing-user-to-default.html
    also this..
    http://bvellinger.blogspot.com/2008/04/default-dashboard-obiee.html

  • How to set selected text color in Spark TextInput

    I'm trying to make Spark TextInputs and MXFTETextInputs look like Halo/MX TextInputs as much as possible, since I have a mix of both Spark and MX TextInputs in my application. I know I can set the
    selection background color to black using focusedTextSelectionColor. How can I set the selected text color to white so it matches the MX white-on-black look?

    This works, if you set the enabled property directly on the s:TextInput:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx">
        <s:layout>
            <s:VerticalLayout horizontalAlign="center" verticalAlign="middle" />
        </s:layout>
        <s:controlBarContent>
            <s:CheckBox id="ch" label="enabled" selected="true" />
        </s:controlBarContent>
        <fx:Style>
            @namespace s "library://ns.adobe.com/flex/spark";
            @namespace mx "library://ns.adobe.com/flex/mx";
            s|TextInput:disabled {
                color: red;
        </fx:Style>
        <s:Group>
            <s:TextInput id="ti" text="The quick brown fox jumps over the lazy dog" enabled="{ch.selected}" />
        </s:Group>
    </s:Application>
    It can get a bit trickier when you're setting the enabled property on a parent container, since (I believe) that the child control's enabled properties are still set to true and just the container is disabled. One possible workaround would be to bind the child TextInput control's enabled property to the container's enabled property. That way the s:TextInput should still go to it's disabled state and you can customize the disabled state's styles to have darker text, or whatever else you want.
    <s:Group id="gr" enabled="{ch.selected}">
        <s:TextInput id="ti" text="The quick brown fox jumps over the lazy dog" enabled="{gr.enabled}" />
    </s:Group>
    Peter

  • How to set the text color in a Canvas?

    When I use (Graphics) g.setColor(255,255,255), then g.drawString("xxx", 0, 0, ....);
    the simulator works well but it can't work in my mobile phone (Nokia 7650).
    What's wrong?
    Thanks.

    do it like this
    g.setColor(255,255,255);//this will set the color for the canvas
    g.fillRect(0,0,ht,wd);//this will fill the rect(screen) with the above color,actually this will be BG color for ur app..ht,wd are the height and width of ur canvas...
    now specify color for the text
    g.setColor(r,g,b);//this color shud ofcourse be diff frm the color set for BG
    now draw the string
    g.drawString("xxx", 0, 0, ....);

  • How to set default font color in Pages

    I don't know why. I did a standard clean install of iWork 08. In Pages, everytime I select to insert a text box, the color of the font defaults to brown rather than black. It's a pain to change it to black all the time. Also I noticed that when I select to insert a line, it also defaults to brown. Any thoughts on why this is happening as the default color and how to fix it?
    Also, almost evertime I do the option click on the text box icon to draw a text box, the cursor changes to the crosshair but the box allows me to draw the with size, but the length of the column automatically can't be drawn- it extends instead all the way off the bottom of the page. In other words I can't really draw the text box to the size I need. I'm new to Pages.

    Fix Your Fonts in Safari 6
    Some Safari 6 stuff
    TextExpander shell script snippet to set Safari 6 default fonts
    Safari 6 on Lion, text much smaller?
    Quickstyle - Canisbos
    Safari 6 default font way too small?

Maybe you are looking for

  • Auxiliary Packaging missing from DESADV IDOC

    Hi Experts, I have a delivery attached to a shipment, when the output for the shipment triggers an outbound DESADV IDOC, the segment E1EDP08 and E1EDP06 contain normal packaging material information, BUT Auxiliary packaging material information (whic

  • Fan runs constantly (not my printer)

    Hi, I've had this problem for a while and it's really getting to me. The fan on my black MacBook (purchased April 2007 and treated very well) runs constantly. Not upon startup, but as soon as I open Firefox it's going until I shut down. I've read abo

  • Credit and Debit Memo (Vendor and Customer)

    Hi Team, Credit Memo raised means - Debit to SAP/Company and Credit to Vendor/Customer? Debit Memo raised means - Credit to SAP/Company and debit to Vendor/Customer? Is this understanding is correct? Thanks Ram

  • Org unit attributes

    How are the Language and Currency attributes for a org unit used ? Is it possible if these attributes are maintained for a  customer then in transactions use customer attributes if available but default to the org attributes if customer attributes ar

  • A bunch of dead pixels?

    Hey, my 3 month old macbook suddenly gained about 15 dead pixels today out of no where :s... i tried the massage option, but it didnt work. what other options can i go to? the dead pixels are kind of annoying, considering the macbook being almost new