Highlighted

Change Text Color in Group

Explorer ,
Jun 24, 2020

Copy link to clipboard

Copied

Hi, I have a quick question. I have a group that consists of paths , but one of the objects is a Text and I want the script to do something different with it than the path objects.

I have tried using the following, but it does not work.

var doc = app.activeDocument;

var group = doc.layers["Icon"].groupItems[0];
    for (var i = (group.pageItems.length) - 1; i >= 0; i--) {
        if (group.pageItems[i].typename == "TextFrameItem") {
            group.pageItems[i].textRange.characterAttributes.fillColor = swatch.color;
        }
    }

 

I also tried to delete the layer which did not work.

        var group = doc.layers["Icon"].groupItems[0];
        for (var i = (group.pageItems.length) - 1; i >= 0; i--) {
            if (group.pageItems[i].typename == "TextFrameItem") {
                group.pageItems[i].remove();
            }
        }

 

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Try changing TextFrameItem to TextFrame

 

-Manan

TOPICS
Scripting

Views

73

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

Change Text Color in Group

Explorer ,
Jun 24, 2020

Copy link to clipboard

Copied

Hi, I have a quick question. I have a group that consists of paths , but one of the objects is a Text and I want the script to do something different with it than the path objects.

I have tried using the following, but it does not work.

var doc = app.activeDocument;

var group = doc.layers["Icon"].groupItems[0];
    for (var i = (group.pageItems.length) - 1; i >= 0; i--) {
        if (group.pageItems[i].typename == "TextFrameItem") {
            group.pageItems[i].textRange.characterAttributes.fillColor = swatch.color;
        }
    }

 

I also tried to delete the layer which did not work.

        var group = doc.layers["Icon"].groupItems[0];
        for (var i = (group.pageItems.length) - 1; i >= 0; i--) {
            if (group.pageItems[i].typename == "TextFrameItem") {
                group.pageItems[i].remove();
            }
        }

 

Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

Try changing TextFrameItem to TextFrame

 

-Manan

TOPICS
Scripting

Views

74

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
Jun 24, 2020 1
Adobe Community Professional ,
Jun 24, 2020

Copy link to clipboard

Copied

Try changing TextFrameItem to TextFrame

 

-Manan

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
Reply
Loading...
Jun 24, 2020 1
Explorer ,
Jun 24, 2020

Copy link to clipboard

Copied

It worked, thank you 😄

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
Reply
Loading...
Jun 24, 2020 1
Resources