Copy link to clipboard
Copied
Hi
Is there any way to duplicate a number of layers and have their expression references update to the new layers?
Example:
I have two layers. LayerA and LayerB. LayerA have this expression:
"thisComp.layer("LayerB").transform.scale"
so when I change the scale of layerB the scale of layerA will follow.
I now select the two layers and duplicate them. I get LayerA2 and LayerB2. LayerA2 is now connected to LayerB and not the new LayerB2.
Did that make sense? Is there a smart work around to have the layer references in expressions update when layers are duplicated? Or do you know any already made scripts that does this?
Thanks,
Jakob
This is exactly what you need: https://aescripts.com/duplicatelayers-n-updateexpressions/
Copy link to clipboard
Copied
Probably the easiest way to do that would be to write your expression to reference the layer above or below the current layer.
Using the scale example tying the scale of one layer to the scale of the layer directly below it like this:
thisComp.layer(index +1).scale
If you duplicate the layers (Ctrl/Cmnd + d) The layer order will not be maintained so you have to copy and paste the pair of layers.
Copy link to clipboard
Copied
That's a good idea for some cases. Not exactly what I'm looking for but a good idea. 🙂 Thanks.
Copy link to clipboard
Copied
Instead of index, you could reference the parent, in case they are parented
😃
Copy link to clipboard
Copied
Working with indices as Rick suggested would be the simplest way. Otherwise you would need to integrate string functions to reconstruct the references and also meticulously adhere to specific naming conventions then, all of which could get quite annoying. In fact in such a case it still may often be simpler to manually update the effect references. Really depends on what numbers of layers you're dealing with and how they are ordered in the timeline, though.
Mylenium
Copy link to clipboard
Copied
Thanks Mylenium. I was mostly asking to check if I was missing something obvious in AE.
I often have several layers connected in a small setup and wish to just duplicate the whole thing without having to worry much about how the expressions are made.
I'll probably end up writing script that does this kind of duplicate I'm looking for.
Copy link to clipboard
Copied
If you have a small setup with a few layers you can pre-compose all of the layers, then duplicate the pre-comp in the Project Panel and then drop the duplicate pre-comp in the timeline.
The only other way I can think of is writing a script that creates the layers and the expressions.
If the layers you are duplicating are shape layers you can write expressions that look at the shape (Rectangle 1 for example) inside the shape layer based on their index, then just duplicate the shape layer or even just duplicate the shape. It would help us help you if we knew what you were trying to accomplish in detail.
Copy link to clipboard
Copied
This is exactly what you need: https://aescripts.com/duplicatelayers-n-updateexpressions/
Copy link to clipboard
Copied
Tomas_Sinkunas nailed it... I just bought the script and it is perfect.
Copy link to clipboard
Copied
Yay! I had been searching but didn't find it. Thanks!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more