I'd never needed to do this before, and I'm surprised it doesn't show as a PathItem property like all the other stroke options too. One way to get around this, though it may be complete overkill and someone might come in and give a much better solution, is to dynamically create an Action which you load, execute, then unload when needed: // Thanks Qwertyfly
// https://community.adobe.com/t5/illustrator/js-cs6-executemenucommand/m-p/5904772#M19673
function setStrokeAlignToInside() {
if ((app.documents.length = 0)) {
return;
}
var ActionString = [
"/version 3",
"/name [ 4",
" 74657374",
"]",
"/isOpen 1",
"/actionCount 1",
"/action-1 {",
" /name [ 9",
" 5365745374726f6b65",
" ]",
" /keyIndex 0",
" /colorIndex 0",
" /isOpen 0",
" /eventCount 1",
" /event-1 {",
" /useRulersIn1stQuadrant 0",
" /internalName (ai_plugin_setStroke)",
" /localizedName [ 10",
" 536574205374726f6b65",
" ]",
" /isOpen 0",
" /isOn 1",
" /hasDialog 0",
" /parameterCount 7",
" /parameter-1 {",
" /key 2003072104",
" /showInPalette -1",
" /type (unit real)",
" /value 1.0",
" /unit 592476268",
" }",
" /parameter-2 {",
" /key 1667330094",
" /showInPalette -1",
" /type (enumerated)",
" /name [ 8",
" 4275747420436170",
" ]",
" /value 0",
" }",
" /parameter-3 {",
" /key 1836344690",
" /showInPalette -1",
" /type (real)",
" /value 10.0",
" }",
" /parameter-4 {",
" /key 1785686382",
" /showInPalette -1",
" /type (enumerated)",
" /name [ 10",
" 4d69746572204a6f696e",
" ]",
" /value 0",
" }",
" /parameter-5 {",
" /key 1684825454",
" /showInPalette -1",
" /type (integer)",
" /value 0",
" }",
" /parameter-6 {",
" /key 1684104298",
" /showInPalette -1",
" /type (boolean)",
" /value 0",
" }",
" /parameter-7 {",
" /key 1634494318",
" /showInPalette -1",
" /type (enumerated)",
" /name [ 6",
" 496e73696465",
" ]",
" /value 1",
" }",
" }",
"}"
].join("\n");
createAction(ActionString);
var ActionString = null;
app.doScript("SetStroke", "test", false);
app.unloadAction("test", "");
function createAction(str) {
var f = new File("~/ScriptAction.aia");
f.open("w");
f.write(str);
f.close();
app.loadAction(f);
f.remove();
}
} We can set the Stroke alignment within an Action, but one problem is that we don't set only the alignment -- we also set the width, dashes, etc. You can record any Action, save it, open the .aia file in a text editor, and replace the ActionString variable above with it's contents to dynamically run it within a script without needing the user to have this action. For the above to work, you'd likely want to clear you app.selection at the beginning of the loop, then set each PathItem.selected to true, run this action just after the stroked = true, then do the styling, and PathItem.selected = false to remove it from the selection so future actions don't affect it.
... View more