Scripting for adding a stroke to the text active or to texts that converted to outline
Copy link to clipboard
Copied
Dear All,
I've tried some ways to create a script that able to add a stroke into text or text that converted. I need a help for that, thanks..
Below is my current script:
#target illustrator
var sel = app.activeDocument.selection;
var obj = sel; // selected the text that I converted or text active.
for (var i = 0; i <obj.length; i++){ // I've tried some, like change "length" to groupItems, compoundPathItems, pathItems, even added the "length" after its (pathItems.length) and its doesn't work.
var textConvertedToOutline = obj[i];
textConvertedToOutline.stroked = true;
textConvertedToOutline.strokeWidth = 5;
textConvertedToOutline.strokeColor = textConvertedToOutline.fillColor;
}
This script only work to rectangle and if for text that converted to outline, I have to released it into compound path..
Thank you,
Regards,
Riko
Explore related tutorials & articles
Copy link to clipboard
Copied
I presume you mean expanded text, which becomes paths within compound paths within groups.
var sel = app.activeDocument.selection;
for (var i = 0; i < sel.length; i++){
var compPaths = sel[i].compoundPathItems;
for (var j = 0; j < compPaths.length; j++) {
var paths = compPaths[j].pathItems;
for (var k = 0; k < paths.length; k++) {
paths[k].stroked = true;
paths[k].strokeWidth = 5;
paths[k].strokeColor = paths[k].fillColor;
}
}
}
Copy link to clipboard
Copied
Thanks for ur solution, its work perfectly. 🙂
Btw, may I have 1 more help?
After trying ur script, it turned out I needed something else.. So can we make rectangle, text and expanded text given strokes in at once?
Thanks
Copy link to clipboard
Copied
var items = app.activeDocument.pageItems;
for (var i = 0; i < items.length; i++){
if (items[i].selected == true) {
if (items[i].typename == "TextFrame") {
items[i].textRange.strokeWeight = 5;
items[i].textRange.strokeColor = items[i].textRange.fillColor;
} else {
items[i].stroked = true;
items[i].strokeWidth = 5;
items[i].strokeColor = items[i].fillColor;
}
}
}
Copy link to clipboard
Copied
@@@@
Thanks for ur reply, that script work perfectly.. 🙂
All the best for you my friend..
Regards,
Riko

