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

AE20200: Use multiple style.set expressions - not working

Engaged ,
Dec 25, 2020 Dec 25, 2020

Greetings all,

 

I'm trying to make use of the new expressions (in JavaScript mode if that helps) to parent text styles between compositions, but I keep running into problems. I've managed to come up with an expression that works when it's by itself, but when I try to stack them like I've seen others do, I get an error starting with the second line: "style.set[whateverelement] is not a function."

 

What I want to do is return specific values from a single layer of "Caption Layout" and apply them to a text layer in another comp, basically so that all I have to do is edit the text style once in "Caption Layout" and it'll propagate everywhere. Yes I could use this to just copy everything:

 

style = comp("Caption Layout").layer("ONE-Line Caption").text.sourceText.style

 

But that returns ALL values, whether I want them or not, and I need certain things different in the template so I can position things properly (specifically, everything in the template is ALL CAPS but I don't want the child layers to inherit that property).

 

These are the expressions I want to stack, exactly as I'm pasting them into the SourceText layer's expression editor:

style.setFontSize(style=comp("Caption Layout").layer("ONE-Line Caption").text.sourceText.style.fontSize);
style.setFauxBold(comp("Caption Layout").layer("ONE-Line Caption").text.sourceText.style.isFauxBold);
style.setAllCaps(style=comp("Caption Layout").layer("ONE-Line Caption").text.sourceText.style.isAllCaps);
style.setLeading(style=comp("Caption Layout").layer("ONE-Line Caption").text.sourceText.style.leading);
style.setTracking(style=comp("Caption Layout").layer("ONE-Line Caption").text.sourceText.style.tracking);

 

Each of these seems to work individually, but put them all together, even separated by a semicolon, and no matter which one is second, that's the one that kicks back an error. So in this case, it says "style.setFauxBold" is not a function, even though that line works perfectly by itself; if I delete that line, it'll do the same with AllCaps, and so on.

 

I know what I'm missing is probably absurdly simple, but I've been Googling for an hour and I can't figure it out. Help please???

TOPICS
Error or problem , Expressions , How to
1.7K
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 ,
Dec 27, 2020 Dec 27, 2020

From your explanation, I think that you want to be able to choose which styles you want to use from the master comp text layer. This is much easier to accomplish using Extended Graphics than it is going to be by adding and editing expressions. If you want it to be just with expressions that at the very least, you will have to set up checkboxes for each property you want to copy and a bunch of IF statements. If you want to ignore All Caps from the master text layer then you'll need an if statement in the slave layer that says if (All Caps = 0) {style = all caps off} else {style = all caps}. That's obviously not the correct language. I'm not sure it is even possible. Dan Ebberts probably would. I don't think the style functions for text layers are very well developed. You can't specify individual lines of text or individual characters, so it's highly unlikely that you would be able to specify which styles you could copy. 

 

On the other hand, this would be fairly easy to do using Extended Graphics.

 

 

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 ,
Dec 28, 2020 Dec 28, 2020

The reason I need to pick and choose like this is because on in my parent comp, the text needs to be all caps so I can better position it (think of letters like Ps and Gs that hang below the line), but in the child comps they need to be mixed-case so we're not shouting at viewers.

 

I'd really prefer to stick with expressions if at all possible. I know Dan Ebberts is a genuis at this kind of thing, maybe he'll have some inputs on how to solve this.

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 ,
Dec 28, 2020 Dec 28, 2020

I think this will work:

s = comp("Caption Layout").layer("ONE-Line Caption").text.sourceText.style;
newStyle = style.setFontSize(s.fontSize);
newStyle.setFauxBold(s.isFauxBold);
newStyle.setAllCaps(s.isAllCaps);
newStyle.setLeading(s.leading);
newStyle.setTracking(s.tracking);
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 ,
Dec 28, 2020 Dec 28, 2020

Actually, that doesn't quite work. I think this does though:

s = comp("Caption Layout").layer("ONE-Line Caption").text.sourceText.style;
style.setFontSize(s.fontSize).setFauxBold(s.isFauxBold).setAllCaps(s.isAllCaps).setLeading(s.leading).setTracking(s.tracking);
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 ,
Dec 28, 2020 Dec 28, 2020

This also seems to work, although I'm not 100% sure why:

 

s = comp("Caption Layout").layer("ONE-Line Caption").text.sourceText.style;
newStyle = style.setFontSize(s.fontSize);
newStyle = newStyle.setFauxBold(s.isFauxBold);
newStyle = newStyle.setAllCaps(s.isAllCaps);
newStyle = newStyle.setLeading(s.leading);
newStyle = newStyle.setTracking(s.tracking);
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 ,
Dec 28, 2020 Dec 28, 2020

Many thanks Dan; I'll give that a go and see what happens. I greatly appreciate it!

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 ,
Dec 29, 2020 Dec 29, 2020

Dan, I don't know how you do it but I'm glad you do it. These expressions get us 99.9% of the way there--they bring over the pieces I need, but there's one minor flaw--they also bring over the text color from the parent.

 

With the start you've provided I can MacGuyver the rest if I need to, but is there a way to do this *without* bringing over the character color?

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 ,
Dec 29, 2020 Dec 29, 2020

Hmmm... I'm not seeing that. I still have color control from the Character panel for my layer with the expression.

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 ,
Dec 29, 2020 Dec 29, 2020

There are a couple of quirks to the source text and what I'm looking to do--I'm trying to have the first word as one color, and the rest of the text as another, and the source text is configured that way.

 

I'll try adjusting my source text to a single color and working with text that didn't previously have an expression (just in case something's stuck, I've seen weirder things with Adobe). I'll report back shortly.

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 ,
Dec 29, 2020 Dec 29, 2020

Once you apply an expression to source text, any previous per-character, per-word, or per-line formatting will be overwritten. You could a apply a fill color animatior to make the first word a different color though.

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 ,
Dec 29, 2020 Dec 29, 2020

This is interesting, it looks like I erred--with your expression I *do* retain control of the text color in the child layer, but even if I have just the first word of my child text selected, changing the color changes *all* of the text in the child layer.

 

I'll give the fill-color animator option a try, but for this specific implementation it looks like expressions aren't the way to go; looks like the way Adobe implemented this, it's an all-or-nothing proposition, even if I pull off the faux bold property from the list. My desired end state is to have the first word in faux bold, in a gold color, and then have the rest in non-faux bold white.

 

I'll keep playing around with it though and see what I can come up with. Still, at worst it still works for two thirds of the project, which is two-thirds more than where I started. Regardless of what happens now your help has been invaluable and will already save me a lot of effort. Many thanks!

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
Enthusiast ,
Nov 23, 2022 Nov 23, 2022
LATEST

Massive thanks to @Dan Ebberts and other commenters on this, I've been trying for a long time to add more text control into my MOGRTS and now I've stumbled across this post, I've found a way to do it!  I know it's an older post but I wanted to share my expression here which works rather well for me.  Instead of copying an existing style, I've found it easier to create a new, blank style and add all the styles from scratch.

 

 

 

output = "test text here";

newStyle = createStyle()
newStyle = style.setFontSize(50);
newStyle = newStyle.setFauxBold(true);
newStyle = newStyle.setAllCaps(true);
newStyle = newStyle.setLeading(3);
newStyle = newStyle.setTracking(2);
newStyle = newStyle.setFontSize(10);
newStyle = newStyle.setFillColor(fColor);
newStyle = newStyle.setText(output);

 

 

 

Now I just need some textbox size controls and I can make my own Essential Graphics panel in a MOGRT!

 

Here's a list of all the possible style properties:

TheArmordillo_0-1669201259516.png

 


Regards, aTomician
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