ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

I want to create automatic script for duplicate and move selected layer after every 2 layers

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Palak Bhatt
I want to create automatic script for duplicate and move selected layer after every 2 layers
on Jul 23, 2020 at 9:00:15 pm

I want to create automatic script for duplicate and move selected layer after every 2 layers

For Example
1 - Image --- (I want this layer going to duplicate and move after 2 layers)
2 - Solid Red
3 - Solid Blue

4 - Image
5 - Solid Red
6 - Solid Blue

This thing continues by script
I have tried duplicate script and move script below

I don't know how to both script collaborate
Please Help if anyone has an idea


-----------------------------------------------------------------------

app.beginUndoGroup("Dublicate Layers");

var thisComp = app.project.activeItem;
var activeItem = app.project.activeItem;
var activeLayers = activeItem.layers;

for (var i = 0; i &lt; thisComp.selectedLayers.length; i++){
curLayer = thisComp.selectedLayers[i].duplicate();

}

app.endUndoGroup();

---------------------------------------------

var activeItem = app.project.activeItem;
var activeLayers = activeItem.layers;
var i = 2;
app.project.activeItem.layer(i).moveBefore(app.project.activeItem.layer(i+2));

------------------------------


Return to posts index

Palak Bhatt
Re: I want to create automatic script for duplicate and move selected layer after every 2 layers
on Jul 24, 2020 at 8:48:11 am

Got the solution
Coding is little rough but its worked

Thanks

app.beginUndoGroup("Dublicate Layers");

var thisComp = app.project.activeItem;
var activeItem = app.project.activeItem;
var activeLayers = activeItem.layers;
var d = app.project.activeItem.selectedLayers[0].index;


for (var i = 0; i &lt; thisComp.selectedLayers.length; i++){
curLayer = thisComp.selectedLayers[i].duplicate();
app.project.activeItem.layer(d).moveBefore(app.project.activeItem.layer(d+4));

}

app.endUndoGroup();


Return to posts index

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