Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions How to Assign Effects to Duplicated Layers Automatically

  • How to Assign Effects to Duplicated Layers Automatically

  • Andac Oktay

    November 27, 2019 at 9:44 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]

  • Dan Ebberts

    November 27, 2019 at 1:35 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

  • Andac Oktay

    November 27, 2019 at 3:33 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!

  • Dan Ebberts

    November 27, 2019 at 3:42 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

  • Andac Oktay

    November 27, 2019 at 4:00 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!

Viewing 1 - 5 of 5 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy