Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions 2000 Layers creation script…..?

  • 2000 Layers creation script…..?

    Posted by Cameron Walser on November 22, 2013 at 11:49 pm

    Hi!

    I have this great comp set up that will eventually have 100 precomps across, and 20 down.

    The comp is set up in such a way that the layers names, and precomps names correspond due to expressions in the precomps, in order to stay linked and do their magic.

    I’ve made it to 100 comps across… and conveniently AE is renaming them sequentially as I duplicate them so no problem there. Also, when I duplicate the precomps in the project window, it also conveniently renames them sequentially. Wahoo!

    Now the problem: I have to option-drag each precomp from the project window onto its corresponding comp to finish this. I will have to do this almost 2000 times. So I’m trying to find a work-around….

    This may not belong in expressions… but the reason for all this is because of the expressions in each of the precoms relating to the comp names- note the first line:

    CL = comp(“Source_x2500”).layer(thisComp.name);
    target = comp(“Source_x2500”).layer(“SourceFTG”);
    samplePoint = CL.toComp(CL.anchor_point);
    sampleRadius = [10,10];
    target.sampleImage( samplePoint, sampleRadius, true, time)

    Think i’m gonna sprain my mouse finger – any words of wisdom / condolences?

    CL = comp("Source_x2500").layer(thisComp.name);
    target = comp("Source_x2500").layer("SourceFTG");
    samplePoint = CL.toComp(CL.anchor_point);
    sampleRadius = [10,10];
    target.sampleImage( samplePoint, sampleRadius, true, time)

    Cameron Walser replied 12 years, 5 months ago 2 Members · 7 Replies
  • 7 Replies
  • Cameron Walser

    November 23, 2013 at 12:06 am

    Ah shoot!

    Here’s another question related to the first – anyone know a way to change the duration of 100’s of comps, all at once?

    As you’ve probably guessed, I did a whole ton of duplicatin’, and the comps I duplicated were not the right length…

  • Dan Ebberts

    November 23, 2013 at 12:57 am

    I think you could do this with a pretty simple script, assuming that the layer names correspond to the precomp names (so that the script can calculate the name of the precomp from the layer name on the fly). The script could find the correct precomp and do a replaceSource() on the layer. The expressions shouldn’t break since the precomp name doesn’t change.

    Like I said, it shouldn’t be too tough, but if you haven’t done any scripting it might be quicker to do it by hand.

    Dan

  • Cameron Walser

    November 23, 2013 at 1:01 am

    I found the answer to one of these questions – https://www.crgreen.com/aescripts/

    selected_comps_changer

    awesome

  • Cameron Walser

    November 23, 2013 at 1:08 am

    Thanks Dan – Yeah, I figured a script would really help here. And no, I have no experience scripting in AE (only in Maya, and even that is limited)…

    I’m up to layer 303, getting carpal tunnel, and considering learning Java just to finish this 🙂

  • Dan Ebberts

    November 23, 2013 at 1:12 am

    It would be a good excuse to learn, even if it takes a little longer. Come back if you decide to try it and get stuck.

    Dan

  • Cameron Walser

    November 23, 2013 at 2:17 am

    Okay – this is awesome, because I think it’s going to work with a little tweaking… and YES! I’m stuck…

    This is what I have, and I think it’s close

    (BTW I pieced it together by reading your motionscript site, and, ironically, another post from you on this site…!)

    I think it gets stuck on mainComp.layer(i) because it doesn’t know what layer “i” is…..?

    {
    var proj = app.project;
    var precompFolder = proj.item(1);
    var mainComp = proj.item(4);
    for (i = 1; i <= precompFolder.numItems; i++) {
    var newSource = precompFolder.item(i);
    mainComp.layer(i).replaceSource(newSource, true);

    }
    }

  • Cameron Walser

    November 23, 2013 at 2:28 am

    BOOYAH!

    I got it – Java also counts folders as project items, so it wasn’t referencing the correct main comp, etc., etc.

    Thank you for the inspiration, btw ! Very satisfying to write an actual script, and see it replace over 1100 layers all at once…

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