Applying a graphics style to object in extendscript

Hi
I've looked around but can't find anything on this although I'm sure its pretty straightforward.
How do I apply a graphic style (pre defined in the GRAPHIC STYLES palette as 'Line 1) to an object, say rectangle, called 'rectangle1' using extendscript.
Can't work this out. (In illustrator CS5 bye the way)
Thanks
Bob

here's a sample, graphic style "add" applied to Selection
var idoc = app.activeDocument;
var sel = idoc.selection[0];
var addStyle = idoc.graphicStyles['add'];
addStyle.applyTo (sel);

Similar Messages

  • Any way to apply or modify Illustrator Effects or Graphic Styles in PathItems from a javascript scri

    I see in the docs for Illustrator javascripting that "scripts cannot create new graphic styles" (lame, btw), and I can't find any member function or variable in the PathItem class that provides a link to any information about applied effects, graphic styles, etc..
    e.g. from a PathItem object I can get the first fill color (in pathItem.fillColor) but I can't seem to find the second one anywhere (fillColor does not return an array). If my PathItem has a dropshadow or a glow effect, or has a graphic style attached to it, I can't seem to find any trace of it, even in the debugger's Data Browser. The class reference docs don't make any reference to any effects or filters at all.
    Am I missing something obvious, or is it actually impossible to write a simple script that, say, adds a dropshadow to every selected item (without blowing away the current fill color)?
    Ken

    Yes, Actions is just AI's built-in macro recorder.
    What's needed is for an Action to be able to reliably include the running of a script. (That's been broken for three versions now.) That would accomodate a range of other possibilities.
    > do you know if there is a current effort or push to expose all the Illustrator functionality to scripts? Or is this something that would be easy to code with the Illustrator SDK?
    I don't know what the direction of AI development is, other than increased bugginess and ever more problematic installers/updaters. ;-)
    Have not yet messed with the SDK.
    There is a range of things that the Javascript implementation doesn't touch (editing Mesh Points, for just one example). Some of it I can understand, because of the tediousness that would be involved in coding.
    JET

  • How to deal with non-continuous shapes and graphic styles

    I am not sure how to frame this question so I will try to describe the problem.
    Imagine I have two shapes. One is a hollowed out circle (like a doughnut chart). The second is a smaller filled in circle. The smaller filled in circle is then poitioned inside the hoolowed out one, so you have like a target but with no "middle" band. What I would like to do is apply a graphic style to the COMBINED shape. The problem is that if I select both shapes and apply the style, each shape will have its own style, whereas what I want is for the style to be distributed over the two shapes as if they were one. And if I use the shape builder tool, when I join the two shapes, from the outer hollowed out circle to the inner filled in circle, I fill in the shape for the "middle band" whereas I want that middle band to be empty.
    You can probably tell I don't know Illustrator and come from Photoshop. In PS, I would simply select my two shapes and apply a style. Since my selection forms a shape that ignores the middle band, the style applies evenly to the whole selection. Can I do something similar in Ilustrator? In reality my network of shapes is more complex that the example above and I do need to keep it a vector.
    Thank you for your suggestions.
    Chris

    There are really two types of Graphic Styles - Object level styles and Group level styles. There is no way to tell which style is which. So if you have an Object level Style and try to apply it to a group of objects or often a compound shape, you get each individual object having the style. If you have a Group level style and try to apply it to only an object, you often get nothing applied.
    It perhaps sounds like you have an Object level style and are trying to apply it to a group.
    There's no way to convert an Object level style to a Group level style or vice versa. The best (and pretty much only) way I've found to get around this is to apply the style to teh correct level then make a note of all the style settings, select the other level and recreate the style for that level.
    Whether or not a style applies correctly has a great deal to do with specific aspects of the style in addition to what level the style was generated from. This is a frustrating aspect of Graphic Styles.

  • Refer to a Graphic Style in a Graphic Style library

    Is it possible to use Javascript to apply a Graphic Style from a save Graphic Style library to an object.
    Or does it have to be in the default graphic styles panel to refer to it in JS.
    Thanks.

    What happens if you try it?
    I think this is your answer: under Document properties, I find
    graphicStyles
    ArtStyles
    readonly
    The graphic styles defined in this document.
    (my emphasis)

  • Envelopes & Changing Graphic Styles

    Hi All,
    When I create an envelope warp with text then apply a "Graphic Style 1" that works fine. If I close the file and reopen the "Graphic Style 1" is correct. When I attempt to change to"Graphic Style 2" the text seems to make a double. If I remove the envelope I can toggle from graphic styles fine.
    Any help is appreciated!! Thank you!!

    Jennifer I am using CS 4 and if I apply a graphic style the text after I do an envelope distort with warp it applies fine if I then select a new graphic style for the text it is now the new graphic style.
    <br />
    <br />I think it should work this way in Illustrator CS2 and CS 3!
    <br />
    <br />I would try to trash the preferences or perhaps you could go step by step for us on how you are doing this!
    <br />
    <br />
    <a href="http://www.pixentral.com/show.php?picture=1NW8z66B8s52GNRTqS8h1FT1rhKZE" /></a>
    <img alt="Picture hosted by Pixentral" src="http://www.pixentral.com/hosted/1NW8z66B8s52GNRTqS8h1FT1rhKZE_thumb.png" border="0" />
    <br />
    <br />
    <a href="http://www.pixentral.com/show.php?picture=1LahzVcWrwhuYNMbsyp7RdPvghOC" /></a>
    <img alt="Picture hosted by Pixentral" src="http://www.pixentral.com/hosted/1LahzVcWrwhuYNMbsyp7RdPvghOC_thumb.png" border="0" />

  • Problem with Batch Processing an Action using a Graphic Style Library

    Hi,
    I have ~100 files in which I need to change the fill and stroke of all the linework. I created Graphic Styles for all my new features. I then created an Action that sets a fill and stroke color, Select Same Fill and Stroke, then applies the new Graphic Style. This repeats for about 20 variations (ie; select all Fill=X, Stroke=Y, then apply Graphic Style A. Select all Fill=X2, Stroke=Y2 then apply Graphic Style B). It runs fine in my test file. The problem occurs when I try to run it in batch mode. I have my new Graphic Style Library set to Persistent, so that it is open for every file. But the action does not apply the new Graphic Styles. It's like it doesn't see/read the Graphic Style Library. I don't get any errors, the action completes. It just doesn't apply anything.
    Does anybody know what I am doing wrong? Are you not able to use an action to apply a graphic style from an added Library?  Do I need to add the graphic styles to the Graphic Styles Panel and have the action reference the Panel, not the Library?
    Any help or insight is appreciated.
    M

    Try this:
    Copy an item that has the Graphic Style to the clipboard before starting the action. Then put a paste step followed by a delete step at the start of the action.
    Hope that helps.
    Mike D.

  • Copying a path creates a duplicate graphic style

    When copying a path by using the the menu commands, if there is any graphic style associated with that path, a duplicate graphic style will be made.  We deal with copying hundreds of lines.  As a result, we are left with hundreds of graphics styles that are duplicates.  This slows the program down by a significant amount.  Is there any fix to this?  We do use the ALT shortcut when we can, which does not create duplicate graphic styles. But, there are some instances where this cannot be used.

    I'm going to take a guess here - if you create a brand new document and do not paste anything into it, but create a path, apply a Graphic Style, then copy and paste that path, you do not see this problem right?
    If that is correct, then my guess is that you frequently work with files where some of the content was created in a much older version of Illustrator and you should refer to this knowledge base article to see if it can help: http://kb2.adobe.com/cps/408/kb408008.html

  • Graphic Styles multiplying when objects are copied

    I have some groups containing lines with graphic styles. Sometimes, when I copy and paste these groups I get new graphic styles with name plus the number 1, 2, 3...
    E.g. "Foo" -> "Foo 1", later "Foo 1" -> "Foo 2"
    Do you know how to avoid this happening?

    That could help - but it seems that it would kill your CS5 specific stuff if you opened the file up in an earlier version?
    Is that not true? Would I lose any other data?
    I tried bcl5462's comment below but the import into cs4 failed completely (I get a "PDF Objects that have been Reinterpreted error" and none of my original document remains), and I'm not sure if it even deals with graphic styles (from http://kb2.adobe.com/cps/408/kb408008.html )
    Open the file with Illustrator CS5 (trial)
    From Window > Actions, "Delete Unused Panel Items"
    Also - try clicking on the brushes panel and selecting all unused brushes - delete.
    Select all unused swatches and delete.
    Save the file.
    Open the file with an older version of Illustrator (e.g. Illustrator CS3)
    This will inform you the file was saved in a newer version of Illustrator and the file will be imported.
    In this process Illustrator CS3 will not import the corrupted brushes or swatches.
    Save the cleaned file.

  • Fill & Stroke applied when changing graphic style to none

    Since you set new rectangles now default to having no stroke and no fill. I think it would be good to also do the same to setting the graphic style to none because it is still applying a white fill & black stroke.
    Maybe its something you just didn't notice when making the update, so I thought I would let you know.
    Thanks,
    Sean

    Vicky,
    You could make the arrowhead  into a Scatter/Pattern Brush, in the following way:
    1) Create the arrowhead,
    2) In the Brushes palette/panel flyout tick New Brush,
    3a1) Tick Scatter Brush,
    3a2) Set the Spacing (as the total length of arrowhead and gap relative to the length of the arrowhead, 200% for gap = length).
    3b1) Tick Pattern Brush,
    3b2) Set the Spacing (relative to the length of the arrowhead, 100% for gap = length).
    Scatter Brush will give you undistorted arrowheads pointing with a slight inaccuracy.
    Pattern Brush will give you bent arrowheads following the path accurately.

  • Applying a gradient to my object results in a tiled pattern.

    Hi,
    I'm not sure how to explain this, and have had trouble trying to find help because I don't really know how to describe what's happening.
    I created a diagonal gradient that I applied to a rectangle with rounded corners. I added the gradient to the swatches pallet. I then created another rectangle which was immediately filled with the gradient swatch. However, the gradient created was shaped like the rectangle and did not line up with the object, thus creating a tiled pattern of the swatch inside the rectangle. Attached image "gradient.jpg" shows the first (normal) gradient and the second (tiled) gradient.
    I moved the rectangle and observed that the gradient did not move with the object. It's like the gradient is stuck to the page and so the tiling pattern changes depending on where I move the rectangle.
    Does anyone know what is going on and how I can get rid of it? I just want a rectangle with a regular gradient across the fill.
    I'm using Illustrator CS4 win.
    Thanks for any help you can provide.
    Steven

    Thanks for the quick reply, Wade.
    Fantastic - it worked just fine. The only thing I noticed is that the swatch doesn't retain the -45 degree angle. Is this something I have to specify in the gradient pallet each time I apply the swatch? Actually I just tested it and worked out that a graphic style contains both the gradient information and the angle.
    Thanks again for your help.
    Cheers,
    Steven
    BTW, were you able to view the image I attached? When I view my post, it has the word QUEUED after it and I can't select it. Sorry, first time I've attached an image... Actually, just worked out there's an 'insert image' button in the editor, so I'll use that from now on. Cheers.

  • Adding Graphic Styles using VBA

    Hi all
    How would I go about applying graphic styles to a path using VBA? I would imagine the following line is wrong because it doesn't work.Any help would be appreciated.
    idoc.GraphicStyles("02-S").ApplyTo (isquare2)

    You're right, it is no fun to have someone give you all the answers. Trial and error is how I learn the most, well it least to make it stick.  Believe me, I go online and try out different things before posting anything on here. Along the way, I might not find the answer I'm looking for, but I always find something out, and most of the time, it's something I needed a while back.
    Yep, I've seen that error quite a few times on numerous projects, it means that the object isn't affected by the methods or properties I'm trying to affect it with.
    However, I was able to make it work by removing the () from the object variable isquare2.
    idoc.GraphicStyles("02-S").ApplyTo isquare2
    Thanks for the challenge Carlos!

  • Graphic styles that use current fill color instead of stomping them?

    Sorry if this is a really stupid, newbie question; I am a stupid newbie.
    If I make a graphic style/appearance, it stores the colors of the fill and stroke and will then stamp that down on whatever else I apply it to (obviously). e.g. if I make a graphic style of a pale yellow fill and a bright orange dropshadow screen to make a glowing neon kind of look, and then drop that style onto a bright blue star, it will make the star pale yellow.
    Is there a way to do a graphic style that _modifies_ the existing appearance instead of stomping it - e.g. dropping that graphic style on my blue star would make a pale blue fill with a bright green dropshadow screen.
    e.g. A graphic style that said "make the new fill 110% value, 85% saturation, same hue as the existing fill color, add a 25 pt dropshadow that has the color of 90% value, 110% saturation, -3 hue of the existing fill color." And then that style dropped on a yellow star and a blue star would result in a glowing neon yellow star and a glowing neon blue star.
    The reason I ask: I have a bunch of geometric shapes of various shades of red, orange, yellow and brown, and would like to see what they would all look like with dropshadows of dark, very desaturated complementary colors (the orange shape gets a dark blue/gray dropshadow, the yellow shape gets a dark purple/gray dropshadow, etc.). Do I have to go in and modify each appearance by hand, or is there some way I can automate that?
    Thanks, and apologies if this is a really obvious question.
    Ken

    You won't get as much control as you describe (specific HSV values), but try putting a negative value in the Drop Shadow dialog's Darkness field.
    To create a Graphic Style that can apply an Effect without disturbing the existing fill/stroke of the object(s), first group the object(s), then apply the Effect (Drop Shadow, etc.) to the Group, and then drag the Group to the Graphic Styles palette.

  • A graphic style I created isn't transforming properly.

    A graphic style I created isn't transforming properly. When I select the object that has the style applied and then try to transform it, it distorts even if I lock the width and height dimensions. Anyone know what I'm doing wrong?

    Hi,
    This seems to be related to "Align to Pixel Grid" option. You need to make sure while creating a new object that this option is unchecked.
    Regards,
    Saurabh

  • Compound paths & graphic style problem (map related)

    Hi all,
    Been banging my head against a wal with this all morning. I'm hoping one of you can help.
    I need to replace portions of a map - it' slots and lots of shapes representing buildings.The original file has shapes made of compound paths (see illustration below). That's great, because the center needs to be knocked out (there are some items underneath that occasionally show through).  I thought I'd try to create a graphic style to replicate the look as closelty as possible, but I cannot get a fill to act as a knockout - so I have the basic shape and effect that I want, but with a colored center instead of a knocked-out one. This is a problem becuase I'll be changing dozens of shapes and I don't want to have to recreate the look on each shape manually.
    Here's a pic to help clarify. The original is on the left, my attempted recreation is on the right. Help!

    First, thansk so much for the help! I'm soooo close, but I keep doing something wrong. Let me run through my steps to see if you can spot where I'm falling down:
    Draw my rotated box (I Object> Compound Path > Make converted it to a compound path becuase I assuemd I'd need that when applying a knockout. I may be wrong there).:
    Fill with white, copy the fill and fill with brown:
    Apply a Transform effect to the 2nd fill (I need the numbers to be absolute, not scale, becuase I need to apply thsi to a variety of shapes but achieve a uniform look):
    I then go to the Opacity on that second layer and check Knockout:
    But when I drop the Opacity down to 0% (with knockout checked) that entire fill layer just goes transparent:
    And if I apply the Knowckout - Opacity settings to the main opacity at teh bottom, the whole thing goes blank:
    Incidentally, here's the shape I'm trying to replicate (I know my attempt doesn't reproduce the connected lower left and upper right rounded corners):
    And here's a small chunk of the map. I'll be changing dozens of these shapes and want to apply that consistent look to them without doing each one manually.
    G'ah! It's driving me nuts! What am I doing wrong?

  • Fonts default to 50 point when applying a paragraph style

    I have run into this several times.  When updating an InDesign file from an older version (now using CS5) when I apply a paragraph style the font defaults to 50 point no matter the style settings.  Is there some way to avoid this.  Currently I'm copying and pasting the graphics into a new file and having to reset the text.  If I copy any of the old text over it causes the same problem.
    Most of our text is copied and pasted from Microsoft Word (old version and new text edits), however, the text that was already in the document and the new text both do the same thing when a style is applied.
    CS5
    Win 7 Pro 64bit

    My original "body" style isn't base on any style and the other styles are based on "body" but none of them (including Basic Paragraph), have 50 as the size.
    I had it wrong in my original question, it's not 50 point size, it's 30 point with 50 point leading, bold, and Myriad Pro (which is my body font) that everything converts to no matter which style I choose.  My basic paragraph style is Times New Roman 12/14.  Body font that everything is based on is Myriad Pro, regular, 10/14.

Maybe you are looking for

  • I have problem installing Flash Builder 4

    When I tried to download from official site and install Flash Builder 4, the alert information popout and said I need to remove beta or test version in advanced. But I do remove beta version of Flash Builder 4, and the alert just keep showing so that

  • RoboHelp 10 For WORD IE10 & IE11 Windows 7 Word 2010 Display Problems

    I have applied fixes from Adobe for Blank Topic Panes in IE10 and a blank TOC in IE11. The instructions indicate the fixes should be made in folder RoboHTML which I have done with no solution to the problems. I am wondering if I should apply the Adob

  • Field changes restart the reviewer process

    Hi Is it possible to configure the Change Management system, so that if a Change Record has been approved, and the Initiator then changes the scheduled start/finish date/time, then the approvals are reset and the CR has to be re-approved ? Thanks Rob

  • Disk Utillity 10.4.6 errors creating .DMG

    I had a client over yesterday, we reformatted his system, installed Tiger 10.4 updated to 10.4.6 installed all of his applications, configured all of his settings, and I've told him now that it's clean, and configured, with permissions repaired, to m

  • Help with BD79 - IDOC conversion rules

    Hi, I'm looking for a "How to" guide to help me with this transaction. I need to do a very simple rule for segment E1MTXHM, in ABAP it can be done like this: IF EMTXHM-TDID = 'IVER'.   E1MTXHM-TDSRPAS = 'Z' ELSE. * Source field ENDIF. But I expect th