Change text color by scripting

Contributor ,
Aug 22, 2022 Aug 22, 2022

Copy link to clipboard

Copied

Hi all,

 

I am using this code to change the color of a text layer. 

 

var mySourceText = layer.property("Source Text");
var textDocument = mySourceText.value;
  
textDocument.fillColor = RGBcolor;
textDocument.strokeColor = RGBcolor;
  
mySourceText.setValue(textDocument);

 

It works fine if the text has the same style. 

If not uniform, it changes the text style to match the first character style.
For example, if I want to change this text to green:

Screenshot 2022-08-23 081837.png
This is what I'd like to get:
Screenshot 2022-08-23 082050.png
However, this is what I get:
Screenshot 2022-08-23 081956.png
Any ideas?

TOPICS
Scripting

Views

61

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

correct answers 1 Correct answer

Community Expert , Aug 22, 2022 Aug 22, 2022

Unfortunately, that's how it works. If your script modifies the text document, everything gets the styling of the first character. You have to use multiple text layers.

Likes

Translate

Translate
Community Expert ,
Aug 22, 2022 Aug 22, 2022

Copy link to clipboard

Copied

Unfortunately, that's how it works. If your script modifies the text document, everything gets the styling of the first character. You have to use multiple text layers.

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
Contributor ,
Aug 22, 2022 Aug 22, 2022

Copy link to clipboard

Copied

Oh!, ok thank you Dan. I'll cope with that.

Cheers!

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 Expert ,
Aug 23, 2022 Aug 23, 2022

Copy link to clipboard

Copied

LATEST

Please vote for this feature request, if you want Adobe to improve this: https://adobe-video.uservoice.com/forums/911311-after-effects/suggestions/37888861-scripting-access-...

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

Make your promotional social content with Adobe Express.

Get started quickly with free templates: