Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


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

Community Beginner ,
May 20, 2021 May 20, 2021

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

TOPICS
Scripting

Views

265

Likes

Translate

Translate

Report

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
Advocate ,
May 21, 2021 May 21, 2021

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

 

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

@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 

Likes

Translate

Translate

Report

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
Advocate ,
May 22, 2021 May 22, 2021

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

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

@femkeblanco 

@@@@

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

 

All the best for you my friend..

Regards,

Riko

Likes

Translate

Translate

Report

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