ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

How to Assign Effects to Duplicated Layers Automatically

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Andac Oktay
How to Assign Effects to Duplicated Layers Automatically
on Nov 27, 2019 at 9:44:29 am

Hello,

I have trouble with the following expression idea. I would like to achieve this;

I have a Shape Layer named as "Bar 1" and an Adjustment Layer named as "Controller" for control the Y Scale of that position. I wrote this expression to control Y Scale;

ySize = thisComp.layer("Controller").effect("Bar 1")("Slider");
[100, ySize]

Everything is ok now. But what i want is; when i duplicate the "Bar 1" Layer there will be "Bar 2". This new layer should assign it's Y Scale to the next Slider controller in the Controller layer. In the Controller layer i created lots of Slider Control.

I think maybe i can use something like "Index + 1" but i could not achieve that.

Thank you!

ySize = thisComp.layer("Controller").effect("Bar 1")("Slider");
[100, ySize]


Return to posts index

Dan Ebberts
Re: How to Assign Effects to Duplicated Layers Automatically
on Nov 27, 2019 at 1:35:58 pm

I haven't tested this, but it is basically how you could extract the number from you layer's name and use it to build the name of the slider:

myNum = parseInt(thisLayer.name.split(" ")[1],10);
ySize = thisComp.layer("Controller").effect("Bar " + myNum)("Slider");
[100, ySize]


Dan



Return to posts index

Andac Oktay
Re: How to Assign Effects to Duplicated Layers Automatically
on Nov 27, 2019 at 3:33:28 pm

Hi Dan!

Thank you, this expression works like a charm. Any time i duplicate the "Bar" layer the new layer takes the new sliders name and assings automatically. So that's perfect!


Return to posts index


Dan Ebberts
Re: How to Assign Effects to Duplicated Layers Automatically
on Nov 27, 2019 at 3:42:44 pm

Glad to hear it. I think I actually made it a little more complicated than it needs to be. This should work as well:

myNum = thisLayer.name.split(" ")[1];
ySize = thisComp.layer("Controller").effect("Bar " + myNum)("Slider");
[100, ySize]


Dan



Return to posts index

Andac Oktay
Re: How to Assign Effects to Duplicated Layers Automatically
on Nov 27, 2019 at 4:00:45 pm

Yes this is working, too.

I also applied this piece of expression into the "Color Control" effect and it works, too.


You are the best and thanks!


Return to posts index

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