Ae Script: Adding generated layer to selected layers
I'm writing a script for some project management things in the studio I work at.
I've got everything working except the most important part.
With the selected layers, the script should create a precomp of the selected layers, and the duplicate of a master layer that is at the bottom of the comp. Right now, everything gets duplicated correctly, and precomped and trimmed correctly. I just can't figure out how to add the duplicated layer into the selected array, so that it gets precomped as well.
Any help? I posted the function below.
If that master layer is at the bottom of layers you can get his index like this:
If that layer have a concrete name:
Then you can push it into the array: