Jump to content
Sign in to follow this  
throb36

After Effects Layer Control Question

Recommended Posts

You can put a checkbox on a layer in one composition, and link the layer/s you want to turn on and off to it from another composition.

 

Apply this expression to the opacity of the layers you want to control..... (rename the comps and layers of course)

 

 

if(comp("Comp 01").layer("Adjustment Layer").effect("Checkbox Control")("Checkbox") > 0)

{100}

else

{0};

Share this post


Link to post
Share on other sites

Yeah, I was trying to avoid the checkbox trick. I did find a solution if anyone is interested.

 

Using layer control to control opacity of layers in a separate comp.

 

1. Add a Null.

 

2. Add the Layer Control to the null.

 

3. Make sure the Comp with the layers is in the current comp.

 

4. Then create a null object for every layer you want to turn on off.

 

5. Use this expression on the Null Object's Opacity:

if (thisComp.layer("Controls").effect("Layer Control")("Layer").index == index) 100 else 0

 

6. Then link all the layer's opacity in the separate comp to the opacity of the Null objects.

comp("Main Comp").layer("Null Object").transform.opacity

 

This works just dandy. Although you can't select "NONE" under the layer control or it will break all the expressions on the null objects. Not sure why.

Share this post


Link to post
Share on other sites

This works just dandy. Although you can't select "NONE" under the layer control or it will break all the expressions on the null objects. Not sure why.

 

None simply returns "false", which isn't a proper layer name, is it not? ;-) You will have to blow up your code with some safety measures like try()catch{} or a custom conditional test....

 

Mylenium

Share this post


Link to post
Share on other sites

Ahhh yes. Have never tried Try/Catch before. But it works very nicely. So instead of the above code, add this to all the Null Objects opacity:

 

try {

if (thisComp.layer("Controls").effect("Layer Control")("Layer").index == index) 100 else 0;

} catch(e) {thisLayer.transform.opacity = 0}

 

 

So if NONE is selected, then all layers opacity = 0. Very nice.

 

Mucho gracias, Mylenium.

 

 

 

Share this post


Link to post
Share on other sites

What is the difference between try/catch vs if/else?????

 

The same like between a potato and a banana. ;-) It's a non-comparison. try()catch{} is a generic security mechanism at the interpreter level that will simply check if the result of the operations returns a valid state like "true", a valid string or whatever. if()else{} is your standard conditional for structuring your code.

 

Mylenium

Share this post


Link to post
Share on other sites

Thanks Mylenium... makes more sense. I guess I just do not know enough about the if/else statement in general, but more wondering what situations you would use them in. Going to try it out and do more research

Share this post


Link to post
Share on other sites

if() else {} is just that - if a condition is met, then do this, else do that. the most common thing is to check foor boolean types or simply compare values, e.g. if a checkbox control is active:

 

myCheck=thisComp.layer.effect("XYZ")("Checkbox");


if (myCheck == 1)
{do this}
else
{do that}

 

Of course there's a million other uses, which can include trying to catch errors. Just check some of the downloadable projects on my site (myleniumstuff.com). There's a lot of that e.g. in PointGlue:XYZ or Symmetrion, where if/else are used to check whether layers or specific properties even exist...

 

Mylenium

Edited by Mylenium

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...