Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Applying expressions via a script – problems with variables

  • Applying expressions via a script – problems with variables

    Posted by Simon Björk on January 4, 2011 at 9:45 am

    Say I have the following script.

    var myComp = app.project.acitveItem;
    var myCamera = myComp.layer(1);
    var myLayer = myComp.layer(2);

    and I want to connect the rotation of my layer to the rotation of my camera. For that example,

    myLayer.rotation.expression = “thisComp.layer(“Camera 1″).transform.zRotation”;

    would work I guess. But what if I don’t know that the camera name is “Camera 1”? Is it possible to use the variable myCamera somehow? I mean, for example it would be easy if I could say: myLayer.rotation.expression = “myCamera.transform.zRotation”;. But that doesn’t work.

    So my question is if it’s possible to use variables set in scripting to your expressions?

    Dan Ebberts replied 15 years, 7 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    January 4, 2011 at 4:11 pm

    In your example, is myCamera a variable within your script that holds the name of a camera? If so, this should work:

    myLayer.rotation.expression = myCamera + “.transform.zRotation”;

    Dan

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