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

Possible to set Source Text from another comp?

Engaged ,
May 18, 2016 May 18, 2016

Let's say there is a Comp1 with a pretty complicated animation that involves a text layer. CompMain is the main comp with 10 instances of Comp1. Each instance has different text, position and timing. Can I set the Comp1 text layer Source Text from an expression in CompMain? If this is not possible, is there any workaround? Otherwise, the alternative would be to have 10 versions of Comp1 with different text and that would be too messy.

TOPICS
Expressions
6.2K
Translate
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
LEGEND ,
May 19, 2016 May 19, 2016

No. Nested comps are just identical instances, nothing more. There is no such thing as settings text based on where and how the layer is used.

Mylenium

Translate
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
Engaged ,
May 22, 2016 May 22, 2016

>>No. Nested comps are just identical instances, nothing more. There is no such thing as settings text based on where and how the >>layer is used.

Thank you for clarifying that.

Would it be possible to write a simple AE script (not an expression) that would take a "template" comp and copy it into multiple comps with different text? This way, changing all the comps would only require changing the "template" comp and running the script.

Translate
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 22, 2016 May 22, 2016
LATEST

>Would it be possible to write a simple AE script...

Yes--here's a simple example that looks for a comp with a name beginning with "template", assumes the text is in the first layer, then applies that text to the first layer of any comp with a name beginning with "text". You'd need to beef it up to meet your specific requirements (and probably add some error detection):

function updateText(){

  for (var i = 1; i <= app.project.numItems; i++){

    var txt = null;

    if ((app.project.item(i) instanceof CompItem) && (app.project.item(i).name.indexOf("template") == 0)){

      txt = app.project.item(i).layer(1).property("Text").property("Source Text").value;

      break;

    }

    if (txt == null){

      alert("Can't find template comp");

      return;

    }

  }

  for (var i = 1; i <= app.project.numItems; i++){

    if ((app.project.item(i) instanceof CompItem) && (app.project.item(i).name.indexOf("text") == 0)){

      app.project.item(i).layer(1).property("Text").property("Source Text").setValue(txt);

    }

  }

}

updateText();

Dan

Translate
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 Beginner ,
May 19, 2016 May 19, 2016

Added comps as layers are not instances.  It's a only dead copy.

If you want to you to a different behavior to each、you must duplicate your "comp 1".

Below is one idea, I don't know for your case.

[main](comp)

-"Control"(Text layer)

--Text-Source Text

1) Add add key in start time.  And type text.(Not in expression field, in Preview panel.)

2) Move timeline, and add keys. And reselect whole words, type another text.

Text layer holds different texts, in each keys.

(And different "character panel" and "Paragraph panel" settings. But expression can use only strings, may be. ):-(

3) Same way, add 10 keys and re-type texts.

[comp 1](comp)

-xxxx(Text layer)

--Text-Source Text -expression:

n = thisComp.name.split(" ")[1];  // " " has 'space' char 

tx = comp("main").layer("Control").text.sourceText;

tx.valueAtTime(tx.key(n).time)

----

Duplicate your *Comp 1" in project panel.

AE increase last number, such as "Comp 2", "Comp 3",,,.

And, drop to Main comps, your "Comp 1" - "Comp 10".

Now, your comp layers show  as "Control" text of match as key numbers.

Translate
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 Beginner ,
May 20, 2016 May 20, 2016

All you need is, short texts, there is also an easier way.

[comp 1](comp)

-xxxx(Text layer)

--Text-Source Text -expression:

thisComp.name

Make duplicates "comp 1" in project panel, and rename.

(not layer names of main comp).

Using thisComp.name (and .split()) is a only way to pass relative arguments from the outside, I think.

Translate
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
Engaged ,
May 22, 2016 May 22, 2016

Thank you. This is an interesting idea, but what if I have 100 text layers and want to change text color, animation timing or some other detail?

Translate
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