Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Duplicate multiple layers and update expression references

Engaged ,
Jan 17, 2020 Jan 17, 2020

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

TOPICS
Expressions
5.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Jan 17, 2020 Jan 17, 2020
Translate
Community Expert ,
Jan 17, 2020 Jan 17, 2020

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.

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 17, 2020 Jan 17, 2020

That's a good idea for some cases. Not exactly what I'm looking for but a good idea. 🙂 Thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 22, 2022 Feb 22, 2022
LATEST

Instead of index, you could reference the parent, in case they are parented

😃

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 17, 2020 Jan 17, 2020

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 17, 2020 Jan 17, 2020

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 17, 2020 Jan 17, 2020

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jan 17, 2020 Jan 17, 2020
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 17, 2020 Jan 17, 2020

Tomas_Sinkunas nailed it... I just bought the script and it is perfect.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 18, 2020 Jan 18, 2020

Yay! I had been searching but didn't find it. Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines