FORUMS: list search recent posts

Control layer visibility with external variable

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Pascal Greuter
Control layer visibility with external variable
on Mar 3, 2014 at 5:06:54 pm

Hi everyone

I have some lower thirds that I need to create in AE. I will read the text from an external text file as described by Harry Frank and others in various tutorials.

So far so good but here's my problem: i have two different lower third backgrounds. One is blue, the other is red. Both are single layers in the PreComp. Now I would like to turn on or off these background layers, based on a variable in the external text field.

Let's say my external text file looks like this:

var comp1 = ["John Spencer", "Actor", "blue"]; -> should turn on blue background layer
var comp2 = ["Tracey Jones", "Director", "red"]; -> should turn on red background layer

Is there a way to do this?

Cheers!
Pascal


Return to posts index

Declan Zimmermann
Re: Control layer visibility with external variable
on Mar 4, 2014 at 6:12:04 pm

Hi Pascal,

The simplest way I know is to set the opacity with an if statement to 100 or 0, depending on the value of the variable.

So, for example, for the Blue layer's opacity, once you set the variable you'd just add the expression below to set it to 100 if the value is "blue", and 0 otherwise.

You would do the same for the red layer, and any additional layers you need turned on or off.

I don't know of any way to actually turn the eyeball on and off. Every time I've encountered this situation folks seem to use opacity.

Cheers,

Declan

if(comp1[2]=="blue") 100 else 0

Declan Zimmermann
Design & Motion
motiongraphicsnyc.com
twitter: @MographNYC


Return to posts index

Pascal Greuter
Re: Control layer visibility with external variable
on Mar 4, 2014 at 9:21:50 pm

Hi Declan

Thank you for your response. I figured out a way last night but your solution is simpler.

I just added the opacity value for the blue and red layer like this:

var comp1 = ["John Spencer", "Actor", 100, 0]; -> turns on blue background layer
var comp2 = ["Tracey Jones", "Director", 0, 100]; -> turns on red background layer

It works just fine

Text Layer Source text and Layer Opacity have the following expression:

try{
myPath = "variables.txt";
$.evalFile(myPath);
eval(thisComp.name)[0]; //The Number is the variable you want to use
}catch(err){
"MISSING";
}


Return to posts index


Declan Zimmermann
Re: Control layer visibility with external variable
on Mar 4, 2014 at 9:53:50 pm

Hi Pascal,

Glad you worked it out!

For tasks along these lines I tend to use Michael Cardeiro's excellent script Comps From Spreadsheet.

If you do this sort of thing a lot you may want to check it out if you haven't already; I've found it very useful.

Cheers,

Declan

Declan Zimmermann
Design & Motion
motiongraphicsnyc.com
twitter: @MographNYC


Return to posts index

Pascal Greuter
Re: Control layer visibility with external variable
on Mar 4, 2014 at 9:58:28 pm

Thanks.

Yes, I have seen this script but never used it. If I have some time I always love to play around with expressions and learn as much as I can but I'm pretty sure that the day will come, where I have some more complex stuff to do and then Michaels script will be very handy.

Cheers!
Pascal


Return to posts index

Antony Turner
Re: Control layer visibility with external variable
on Aug 13, 2014 at 1:22:18 pm

Hi Chris,

I'm just wondering if you found a solution to automating your templates?
I'm in the process of developing a solution which would possibly do what you need.
At a high level, it allows you to generate multiple videos from a single template.
The process would be:
1) Create the template
2) Upload the template to the system
3) Through our web interface, for each team, you simply upload image(s), fill in text/captions/etc, change settings, and press [render]. The system then takes care of opening AE, opening the template, replacing the images/texts with the custom items, rendering in AE, encoding again (2 pass) with handbrake, and then making the final video available.

I also supports producing a draft/preview video, SD, and HD, all selectable.

At this stage the system is in beta, so I am looking for users/testers. Let me know if this is of interest to you.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]