Skip to main content
Ilya217794162hc3
Participating Frequently
Feb 22, 2023 2:02 PM UTC
In Development

failed to set values for TextDocument on first try.

 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 is closed to new replies. Start a new post to keep the conversation going.

4 replies

Ilya217794162hc3
Participating Frequently
Jan 9, 2024 3:32 PM UTC

Translate
JohnColombo17100380
Community Manager
Community Manager
Nov 21, 2023 3:39 PM UTC

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

 

- John, After Effects Engineering Team 

Translate
Adobe Employee
Nov 21, 2023 5:33 AM UTC

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

Translate
Adobe Employee
Sep 27, 2023 5:00 PM UTC

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

 

Douglas Waterfall

After Effects Engineering

Translate