Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Pre-comp uses parents time line?

  • Pre-comp uses parents time line?

  • Paul Stevenson

    June 17, 2015 at 12:24 pm

    Is it possible for a child pre-comp use the parents timeline for it’s timings?

    So if I pass a child values from the parents timeline, based on it’s frame position, and those values are put into an a expression that animates something. Is it possible to have the animation (in the child pre-comp) honour it’s position in the parents timeline and ignore it’s own timeline?

    Thus when I move the child about in it’s parents time (thus the values it’s given adjust), it doesn’t try and use it’s own timeline and end up with offset timings (because it’s been moved in time on the parents timeline and the timelines times don’t match up)?

    I am effectively using the pre-comp as a container, a directory if you will, to keep things tidy on the main (parent) timeline.

  • Dan Ebberts

    June 17, 2015 at 4:09 pm

    You have to know the name of the parent comp, and then an expression can look for its own comp as a layer in the parent comp and compensate for the offset timelines with something like this:

    C = comp(“parent comp”);
    ctrl = C.layer(“controls”).effect(“Point Control”)(“Point”);
    L = C.layer(thisComp.name);
    ctrl.valueAtTime(time+L.startTime)

    Dan

  • Paul Stevenson

    June 26, 2015 at 4:26 pm

    Dan thanks for the response and sorry for the delay in getting back to you, I have been busy on other projects and just got back to this today.

    I am not quite sure what your code is doing and I definitely couldn’t get it working, but I am a bit of an expressions noob.

    However I did manage to find a solution.

    As I said, I am passing values from the parent to the child, so I merely adjusted those values. Instead of using a straight…

    timeToFrames(thisLayer.inPoint)

    …on a slider that is then read by the child, I adjusted it a little:

    TimePoint=timeToFrames(thisLayer.inPoint);
    TimeOffset=timeToFrames(thisLayer.startTime);

    TimePoint-TimeOffset;

    For the benefit of anyone reading this that doesn’t understand the above:

    This now takes the in point and the point in time on the layer that it starts (subtly two different things – one being a shifted time and one being a cropped to time – It’s quite probable that both can exist at the same time) and takes one from the other. This calculates the time adjusting for offset. The child can then read this.

    For anyone looking for code on how a child can read something from the parent, this will get you started:

    comp("Parent").layer(thisComp.name).effect("Slide START")("Slider");

    Just in case anyone is searching for the same things I was a few days ago.

  • Josh Acason

    July 11, 2021 at 2:03 am

    Man. Thank you so much Dan! 6 years on, I really appreciate your contribution, made an account just to say thanks haha.

     

    I used your expression to send trapcode soundkeys values back to a child comp – it’s so obvious when you know, but thank you man.

Viewing 1 - 4 of 4 posts

Log in to reply.

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