Copy link to clipboard
Copied
I used your bit of script and its worked really well!
//Apply Outline to selected shape
for (var i = 0; i < sel.length; i++) {
var gStyle = doc.graphicStyles.getByName("Outline");
gStyle.applyTo(doc.selection[i]);
}
I've noticed one thing that I can't explain.
The graphic style is set to "Align Stroke to Outside" but occasionally it sets the graphic style to "Align Stroke to Center" is there something I can change with my code to ensure it always applies as "Align Stroke to Outside"?
Thank you!
Copy link to clipboard
Copied
Hi @BryanPagenkopf, I don't think that the scripting API provides access to the "Align Stroke to" options. Hope I am wrong. But also, I couldn't reproduce your problem occasionally it sets the graphic style to "Align Stroke to Center". Do you have a test file that demonstrates this problem? A possible solution is to reset the appearance and then re-apply the graphic style? Just thinking aloud.
- Mark
P.S. the line var gStyle = doc.graphicStyles.getByName("Outline") should be outside the loop, otherwise it unnecessarily gets evaluated for every item selected.
Copy link to clipboard
Copied
@m1b Thanks for the P.S. comment, made the change! Funny thing about my issue... I can't recreate it now either. I've tried repeatedly and the graphic style is applying correctly.
Copy link to clipboard
Copied
Please post back if you do find the elusive error caseāI'm interested to nail it down. One thing to try if you haven't already is to quit Illustrator and VSCode and run again. Sometimes variables can be persistent in memory and this can have the result of making it look like everything is running fine until you next boot Illustrator and a variable is missing or different. - Mark
Copy link to clipboard
Copied
Just jumping in here. When I automated applying styles and had the same issue, tt was on compound paths. I dont remember if it was when they were compound paths or if I converted them to compound paths it resolved the issue. You could test easily enough manually then automate that as a first step if it resolved it.
Copy link to clipboard
Copied
@mcs_dean, that rings true! @BryanPagenkopf can you confirm that your problem occurs with compoundPathItems? Maybe try making two separate path items with different settings for align stroke, then compound them? Some edge case?