Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Change precomp duration and inPoint of following precomps

  • Change precomp duration and inPoint of following precomps

    Posted by Daniel Vella on November 22, 2022 at 9:35 pm

    Hi,

    I’m trying to build a script that changes the duration of a precomp and any layers inside it from 1 second to x seconds as an example, while also moving the inPoint of any following precomps or layers so that they don’t overlap.

    Attached are two photos of what I want to achieve. I want to change the duration of precomp “Two” from 1 second to 2 seconds and move precomp “Three” to start from the 3rd second instead of the 2nd so they don’t overlap.

    I tried changing the inPoint and outPoint of the precomp, but it doesn’t seem to change. Any help or guidance is greatly appreciated.

    Dan Ebberts replied 3 years, 9 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    November 22, 2022 at 10:57 pm

    This is very simplified and very specific to your example, but hopefully it gives you the idea:

    var mainComp = app.project.activeItem;
    var two = mainComp.layer("Two");
    two.source.duration = 2;
    two.outPoint = 3;
    var three = mainComp.layer("Three");
    three.startTime = 3;
    var twoComp = two.source;
    for (var i = 1; i <= twoComp.numLayers; i++){
    twoComp.layer(i).outPoint = 2;
    }
  • Daniel Vella

    November 23, 2022 at 7:22 am

    Hi Dan, thanks for your reply. I’ve run your script and precomp “Three” was moved correctly, however, the duration of precomp “Two” changed to less than a second. Any idea why this could happen, please? Could it be that duration doesn’t accept seconds? Thanks

  • Dan Ebberts

    November 23, 2022 at 7:48 am

    Ah, I hadn’t noticed that your layers have been time stretched to 3.3%, so you’d have to factor that into the calculation of how long to set the duration of the source comp.

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