Ah good question. Graphic styles do contain the appearance attributes as you see them in the appearance panel.
I've never scripted graphic styles, but I had a quick look at the docs and found ArtStyle. You seem to be able to do something like:
var myGraphicStyle = app.activeDocument.graphicStyles.getByName("my style");
myGraphicStyle.applyTo(myPageItem);
I haven't tested, but see if that's helpful.
- Mark
After several attempts and modifications, I've finally crafted a script that seems to be functioning correctly. Below is the solution script that worked for me:
// Ensure an active document is open and a page item is selected
if (app.documents.length > 0 && app.activeDocument.selection.length > 0) {
var doc = app.activeDocument;
var myPageItem = doc.selection[0];
try {
// Try to get the graphic style and apply it
doc.graphicStyles.getByName("StyleName").applyTo(myPageItem);
} catch (e) {
// Handle error silently
}
}
I hope this can be of help to anyone who might be facing similar issues.