Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Layer width as it moves on Z axis

  • Layer width as it moves on Z axis

    Posted by Saulo Dal pozzo on March 20, 2024 at 1:33 pm

    I’ve made this example to simplify the original situation; The red circle has the following expression in its position:

    a = thisComp.layer(“CIRCLE-BLUE”);

    b = a.toWorld(a.transform.anchorPoint);

    c = thisComp.layer(“CIRCLE-BLUE”).content(“Ellipse 1”).content(“Ellipse Path 1”).size;

    [ (b[0]+c[0]/2) , b[1] ]

    It is using the blue circle size to be parented to the right corner of the blue circle.
    But the blue circle is a 3D layer, and when I move it on the Z axis, the red circle can’t calculate its new position based on the blue circle’s size referent to the comp.

    Is there a way to define blue circle’s width in real time as it moves on the Z axis?

    Brie Clayton replied 3 weeks, 1 day ago 3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    March 20, 2024 at 3:22 pm

    I think it would be more like this (assuming your anchor point is centered):

    a = thisComp.layer("CIRCLE-BLUE");
    b = a.content("Ellipse 1").content("Ellipse Path 1").size;
    c = a.toComp(a.anchorPoint + [b[0]/2,0]);
  • Saulo Dal pozzo

    March 20, 2024 at 5:33 pm

    I knew you would be the one to solve this! I had to adapt it a bit to fit my original plan, which was to have a line snap to the corner of an ellipse as if it was touching it. I’ll upload the results, this is the finished line of expression:

    // LAYERS

    posP = thisComp.layer(“LINHA: Path 1 [1.1.2]”).transform.position;

    bola = thisComp.layer(“BOLA-AZUL”);

    diametro = thisComp.layer(“BOLA-AZUL”).content(“Ellipse 1”).content(“Ellipse Path 1”).size;

    posB = bola.toComp(bola.anchorPoint);

    pontaB = bola.toComp(bola.anchorPoint + [diametro[0]/2,0]);

    posB3D = [posB[0],posB[1]];


    raio = sub(pontaB,posB)[0];

    c = sub(posB, posP);

    modc = length(posP,posB3D);

    alfa = -Math.acos(c[0]/modc);

    theta = Math.asin(raio/modc);

    beta = alfa-theta;

    modv = Math.sqrt(Math.pow(modc,2)+Math.pow(raio,2));

    v = [Math.cos(beta)*modv, Math.sin(beta)*modv];

    add(posP, v)

  • Brie Clayton

    March 20, 2024 at 9:52 pm

    Thank you for solving this, Dan!

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