Skip to main content
Ilya217794162hc3
Participating Frequently
February 22, 2023

failed to set values for TextDocument on first try.

  • February 22, 2023
  • 4 replies
  • 533 views

 When executing a simple script, it fails to set some text styles with SetValue on the first try.

var targetLayer = app.project.activeItem.layer(1);

var strArr = [
    "‏حفظ حساب في الأرشيف",
    "Archive an Account",
    "เก็บบัญชีถาวร",
    "एक खाते को आर्काइव करें"
];

var fntArr = [
    "NotoSansArabic-Bold",
    "Roboto-Bold",
    "NotoSansThai-Bold",
    "NotoSansDevanagari-Bold"
];

lang = 1; // select num (0-3) for change language and font

var textProp = targetLayer.property("ADBE Text Properties").property("ADBE Text Document");
  var textDocument = textProp.value;

  textDocument.resetParagraphStyle();
  textDocument.resetCharStyle();
  textDocument.font = fntArr[lang]; 
  textDocument.text = strArr[lang];
  textProp.setValue(textDocument); 

  //uncomment it for normal work 
  //textProp.setValue(textDocument);

Hello! I use a very large number of layers (<1000) in my projects and use the dictionaries of JSON to localize them into different languages. From profiling the code, I can tell that the longest part of running my script is applying "textDocument" to the layer using setValue(). Therefore, it is highly undesirable to repeat this action.

This topic has been closed for replies.

4 replies

Ilya217794162hc3
Participating Frequently
January 9, 2024

JohnColombo17100380
Community Manager
Community Manager
November 21, 2023

Per @Douglas_Waterfall 's comment about this fix being in Beta, marking this thread as Started.

 

- John, After Effects Engineering Team 

Adobe Employee
November 21, 2023

This has now been fixed in beta.

 

https://community.adobe.com/t5/after-effects-beta-discussions/per-character-scripting-public-beta-announcement/td-p/14247138

 

Douglas Waterfall

After Effects Engineering

Adobe Employee
September 27, 2023

I can reproduce this oddity as well and am looking into it.

 

Douglas Waterfall

After Effects Engineering