Copy link to clipboard
Copied
I am creating a script to distribute to users.
The package contains 1 script and a graphic style library that is required to apply a 3d effect in the script.
Is there a way to open the graphic style library from the script?
The script and library will both be located in the Adobe Illustrator Presets.
I am trying to reduce the amount of actions required by the user so that they only need to run the script without having to open the graphic style library first.
Below code occurs error: target layer cannot be modified
But no unvisible or locked layer
var style = app.activeDocument.graphicStyles.getByName("Jive_GS");
style.applyTo(myvector);
Copy link to clipboard
Copied
Unfortunately a script cannot simply import a graphic style library. As a work-around, take advantage of the Illustrator art handling abilities by keeping all your graphic styles attached to at least one art shape (each) in one .ai file. Then have your script open the file and duplicate the art into the user's previously-active document and close your new document. This will populate all of the graphic styles into the user document.
Copy link to clipboard
Copied
Thanks for the help, very much appreciate it !
But can you provide real world code example for that please ? When I execute it, nothing happens.
var style = app.activeDocument.graphicStyles.getByName("Jive_GS");
style.applyTo(myvector);
Copy link to clipboard
Copied
What does your document structure look like when you are executing this? What is "myvector"? Your example looks like it should work just fine, provided there are necessary pre-conditions in place such as an open Ai document, a graphic style called "Jive_GS" inside it as well as some art in the document which would have the 'myvector' reference in the script somewhere above the snippet you pasted.
Copy link to clipboard
Copied
thisPlacedItem = doc.groupItems.createFromFile(f);
var style = app.documents[1].graphicStyles.getByName("test22");
style.applyTo(thisPlacedItem);
This error happens: Error: Target layer cannot be modified
Copy link to clipboard
Copied
Not sure, but if your 'doc' isn't documents[1], and you are trying to put a style which exists in app.documents[1] into doc, first duplicate an art item with the style into the doc document. I think you have to duplicate it into a document's container, so use doc.layers[0] as the destination. Now that your item is in the document, the graphic style should be usable by the script next.
If that's not the solution, maybe check to make sure your top-most layer in your doc isn't hidden or locked. Perhaps the doc.groupItems.createFromFile is running into a problem due to hidden or locked layer where it is trying to create the item.
Copy link to clipboard
Copied
Hello,
I'm really interresting with this features.
Can Illustrator team can add support for creating/editing/deleting graphic styles and/or aspect.
I need to apply a set of graphic styles on different layers. After applying styles, I want have possibility to update or change grphic styles in one click...
Please integrate this features.
Thanks
Copy link to clipboard
Copied
the best place to add feature requests is here
SDK/Scripting Bugs and Features: Top (26 ideas) – Adobe Illustrator Feedback
Copy link to clipboard
Copied
Thanks
Find more inspiration, events, and resources on the new Adobe Community
Explore Now