Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions sourceRectAtTime individual group within layer

  • sourceRectAtTime individual group within layer

    Posted by Thomas Collier on June 24, 2020 at 9:21 pm

    What is the proper syntax after thisLayer to access individual content groups or paths within a shape layer?

    I know how to use sourceRectAtTime to obtain the overall dimensions of a layer, but is it possible to use it to access an individual group of layers within a shape layer? My issue is I have two groups, with multiple shapes beneath each. I want to center my anchor point on only one of the groups. However I am unable to pickwhip any of the contents of my shape layer.

    w = thisLayer.sourceRectAtTime(time,false).width;
    h = thisLayer.sourceRectAtTime(time,false).height/2;
    t = thisLayer.sourceRectAtTime(time,false).top;

    [w,h+t]

    Filip Vandueren replied 5 years, 10 months ago 2 Members · 1 Reply
  • 1 Reply
  • Filip Vandueren

    June 29, 2020 at 1:08 pm

    Nope, sourceRectAtTime() is a method of the layer-object only.

    There are tricks to do what you want though: if there are given times at which a group is the only thing visible in the layer, that would yield the correct value.

    So, setting the scale and position of the offending group to [0,0] achieves the effect of removing that group’s influence to the bounding box…
    (Given that the remaining Group is at it’s default position/anchorpoint [0,0])

    You could manually set up some keyframes beyond the reach of your current rendering Work Area where that’s true. Or I’ve seen approaches where that information is “hidden” at times before zero, with expressions:

    The groups that you want to exclude, should get this expression for both Group Position and Group Scale:
    time>=0 ? value : [0,0];

    The anchor-point of the layer should get this expression (note the time of -1):
    sr=thisLayer.sourceRectAtTime(t = -1, includeExtents = true);
    w=sr.height;
    h=sr.height;

    t=sr.top;
    l=sr.left;
    [l,t] + [w,h]/2;

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