Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Scripting for adding a stroke to the text active or to texts that converted to outline

Community Beginner ,
May 20, 2021 May 20, 2021

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

TOPICS
Scripting
918
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 21, 2021 May 21, 2021

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;
        }
    }
}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 21, 2021 May 21, 2021

@femkeblanco 

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 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 22, 2021 May 22, 2021
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;
        }
    }
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 23, 2021 May 23, 2021
LATEST

@femkeblanco 

@@@@

Thanks for ur reply, that script work perfectly.. 🙂

 

All the best for you my friend..

Regards,

Riko

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines