Stroke property on Mac
The stroked
property of the PathItem object contains a boolean value that it has a stroke. We think we can activate it in the loop for all selected objects.
var newColor = new RGBColor();
newColor.red = 0;
newColor.green = 0;
newColor.blue = 0;for (var i = 0; i < activeDocument.selection.length; i++) {
var item = activeDocument.selection[i];
if (!item.stroked) {
item.stroked = true;
item.strokeWidth = 1; // units: pt
item.strokeColor = newColor;
}
}
This works in Adobe Illustrator on Windows, but not always on Mac. Because bugs occur not only between updates of Illustrator, but also in the same version on different operating systems.
So on Mac in Illustrator CC 2019, CC 2020, the script adds a stroke if one object is selected, but with more than one, it’s up to chance. Or the script can save the fill and stroke from one object in a variable, and insert only the fill on the other object. CC 2018 didn’t have this problem.

The CC 2021 version on Macs fixed this. But there is no guarantee that it won’t happen again with the next update.

I found the bug when I made the StrokeColorFromFill script. It assigns a fill color to the stroke, and if the object doesn’t have a stroke, there’s an option in the dialog box to add one.

So I added an OS and Illustrator version check when generating the window to hide the “If there is no stroke, add it” checkbox.
var USER_OS = $.os.toLowerCase().indexOf('mac') >= 0 ? 'MAC': 'WINDOWS';
var AI_VER = parseInt(app.version);if (USER_OS == 'WINDOWS' || (USER_OS == 'MAC' && AI_VER >=24)) {
var isAddStroke = dialog.add('checkbox', undefined, 'If there is no stroke, add it');
isAddStroke.value = true;
}