• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Help with addText()

Explorer ,
May 20, 2023 May 20, 2023

Copy link to clipboard

Copied

I'm passing to addText() a TextDocument from an existing text layer with some modifications. The modified text itself is passed, but other properties, like font and fillColor are not passed. Instead, the current font and fill color in the Character panel are set. Am I doing something wrong? Do I have to manually set every property after the fact?

 

let selectedLayer = app.project.activeItem.selectedLayers[0];
let sourceDocProp = selectedLayer.sourceText;
let sourceTextDoc = sourceDocProp.value; 

let newTextDoc = sourceTextDoc;
newTextDoc.text = "Changed text";
newTextDoc.fillColor = [0,0,0];
newTextDoc.font = "Arial";

let newTextLayer: TextLayer = app.project.activeItem.layers.addText(newTextDoc);

 

TOPICS
Scripting

Views

326

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
Explorer ,
May 20, 2023 May 20, 2023

Copy link to clipboard

Copied

May have answered my own question. Seems like addText() is only accessing the text property of the TextDocument. I have to run setValue() and pass the TextDocument a second time to update everything else.

let newTextLayer: TextLayer = app.project.activeItem.layers.addText(newTextDoc); // Sets just the text
const newTextLayerDocProp = newTextLayer.sourceText;
newTextLayerDocProp.setValue(myTextDoc); // Sets all the other text properties.

Votes

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 ,
May 20, 2023 May 20, 2023

Copy link to clipboard

Copied

The documentation of addText says that it supports both a string or a TextDocument:

https://ae-scripting.docsforadobe.dev/layers/layercollection.html#layercollection-addtext

If it ignores all additional properties of the TextDocument, this sounds like a bug and I recommend that you report it. Good that you found a workaround 🙂

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

Votes

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
Explorer ,
May 21, 2023 May 21, 2023

Copy link to clipboard

Copied

LATEST

Yeah, I also interpreted the documentation that way! I'll file a bug report. Thanks.

Votes

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