Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Keep expressions intact when moving a control layer to another comp

  • Keep expressions intact when moving a control layer to another comp

  • Johan Andreasson

    March 3, 2016 at 7:01 am

    I have a quite complicated pre-comp that I control with a Null object with expression controls such as slider controls etc. This Null object is located in the head comp and not the pre-comp itself.

    Now, I want to move this control layer, Null, to yet another comp. But when doing so, all of the expressions break and it would be a real pain to go in and correct all the different expressions.

    Question: How do I move the Control layer to another comp and keep the expressions intact? This seems at least in my mind something that easily could be done and should be as basic as when you rename a comp the expressions update automatically wth that new name?

    Thank u.

    ~ Johan

  • David Conklin

    March 3, 2016 at 4:55 pm

    Hey there,

    This solution is not super straightforward, but also not that complicated. ESTK provides a handy little app.project.autoFixExpression(oldText, newText) command, that you can use to batch-fix expressions. This is the main thing you’re looking for.

    The issue is, autoFixExpressions will only fix expressions that YOUR SCRIPT causes to break, not preexisting errors. So, in the script here’s what we do.

    1. Make variables that have the names of the comps we need (the controller comp, the pre-comp, and the new comp).
    2. Find these comps.
    3. Copy controller from the controller (‘top’) comp, to the new comp.
    4. Remove controller from top comp, thereby breaking the expression.
    5. run .autoFixExpressions(topCompName, newCompName) to fix the expressions.

    Here’s the script. Hope it helps!

    (function fixExpressions(){
    app.beginUndoGroup("Fix expressions.");

    var proj = app.project

    var topCompName = "Top Comp"; // comp where controller lives now.
    var preCompName = "Pre-Comp"; // comp where expressions are (that break).
    var newCompName = "Another Comp"; // comp you want the controller in.

    // holders for comps.
    var topComp,preComp,newComp;

    // loop through project and get the comps.
    for (var i = 1; i <= proj.numItems; ++i){
    case topCompName:
    topComp = proj.item(i);
    case preCompName:
    preComp = proj.item(i);
    case newCompName:
    newComp = proj.item(i);

    // move controller

    // delete from old comp.

    // fix expressions


    David Conklin
    Motion Designer

  • David Conklin

    March 3, 2016 at 5:03 pm

    Something I forgot to add, is that you’ll need to change line 31 and 34, ‘topComp.layer(“Controller”)’ to the name of your controller. If your control layer is just named ‘null’, you’d change them to ‘topComp.layer(“null”)’.

    Best of luck!

    David Conklin
    Motion Designer

  • Adira Kessler

    February 11, 2021 at 2:57 pm

    What there are expressions in multiple comps?

  • Yoan Boisjoli

    February 21, 2021 at 1:27 pm

    I think you could do it with this script:

    All you’d need to do is search and replace the old path to the new one.

Viewing 1 - 5 of 5 posts

Log in to reply.

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