Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Enable freeze frame with a checkbox control

  • Enable freeze frame with a checkbox control

    Posted by David Cabestany on February 23, 2021 at 12:51 am

    I’m trying to create a checkbox control so a layer freezes in time when enabled and plays back normally when not.

    k1=timeRemap.key(1).value;

    k2=timeRemap.key(2).value;

    f=thisComp.layer(“xp”).effect(“freeze”)(“Checkbox”);

    if

    (f==1)

    {linear(time,k1,k2,layer.inPoint,layer.outPoint)}

    else

    {166}

    When enabled it gives an error (layer is not defined) and when disabled it freezes the layer at the out point, not the frame I want (166).

    Any suggestions are greatly appreciated.

    David Cabestany replied 3 years, 6 months ago 3 Members · 9 Replies
  • 9 Replies
  • Dan Ebberts

    February 23, 2021 at 1:03 am

    For one thing, time remapping wants seconds, not frames. The other part isn’t completely clear to me but it sounds like your expression needs calculate the total time the checkbox has been in the on state up to the current time. To do that you need to loop through the checkbox keyframes and add up all the segments since time zero where the checkbox was on (plus the contribution of the current, incomplete segment if the checkbox is currently on). Not too tough, but not trivial.

  • David Cabestany

    February 23, 2021 at 1:05 am

    It’s too much hassle for what I need. The checkbox is not keyframed. I just need to render a version with one layer animated and one without.

    I’ll just freeze the frame, render and unfreeze it again.

    Thanks anyway for looking into it.

  • Brendon Murphy

    February 23, 2021 at 3:35 am

    David, if it helps, here’s a script you can run to quickly duplicate the selected layer and freeze it at the current frame. It also puts a checkbox on the frozen layer that allows you to quickly toggle it on/off (if you prefer that over the layer switch).

    app.beginUndoGroup("Freeze Layer");

    var activeComp = app.project.activeItem;

    var activeLayers = activeComp.selectedLayers;

    var currLayer = activeLayers[0];

    //duplicate and freeze layer at the current time

    var frozenLayer = currLayer.duplicate()

    frozenLayer.timeRemapEnabled = true;

    var timeRemapProp = frozenLayer.property("ADBE Time Remapping");

    var currTime = frozenLayer.time

    var firstTime = frozenLayer.inPoint;

    var lastTime = frozenLayer.outPoint;

    timeRemapProp.setValueAtTime(firstTime, currTime);

    timeRemapProp.setValueAtTime(lastTime, currTime);

    //add toggle switch for freezing or unfreezing

    var freezeSwitch = frozenLayer.Effects.addProperty("Checkbox Control");

    freezeSwitch.name = "Enable Freeze"

    freezeSwitch("Checkbox").setValue(true);

    frozenLayer.transform.opacity.expression = 'if(effect("Enable Freeze")("Checkbox")==1){100;}\relse\r{0;};';

    app.endUndoGroup();

    Brendon

    Free After Effects Tools

  • David Cabestany

    February 23, 2021 at 11:09 pm

    Brendon, thanks so much. I already copied the text and compiled it, let me try it later (I’m in the middle of a massive render right now), and will let you know if it works.

    Thanks so much for taking the time to write this!

  • David Cabestany

    February 24, 2021 at 12:42 am

    Hi Brendon,

    I’m trying your script now and I’m getting a syntax error at line 1. I don’t really know a lot about scripting (more like nothing, really). Do you what could be causing it?

    I tried on both the Script UI folder and the other one.

    Thanks in advance.

  • Brendon Murphy

    February 24, 2021 at 6:33 am

    David,

    I’m not sure how you are attempting to compile it, but in AE you can go to File>Scripts>Open Script Editor. Paste the code into the editor and then save it as a jsx in your scripts folder (not Scripts UI). Restart After Effects.

    To run the script:

    -Move the playhead to the frame you want, and then select the layer you want to freeze

    -Go to File>Scripts>Freeze Layer.jsx

    That should do it!

  • David Cabestany

    February 24, 2021 at 4:16 pm

    Thanks Brendon, I used Brackets to compile it. I tried using adobe’s script editor launching it directly from within AE but it won’t run anymore, it’s a 32bit application and it is no longer being updated, instead, it returns an error stating it’s not installed and tells you where to go to install it. When I go there (Creative Cloud app) I see that it is installed but grayed out. I’m on Mac OS Big Sur.

  • Brendon Murphy

    February 24, 2021 at 5:43 pm

    Interesting – I do not have the script editor issue on PC. You could try saving the script as a plain text file and then manually changing the extension to jsx. Otherwise, I could send you a download link when I’m back near a computer.

  • David Cabestany

    February 25, 2021 at 11:29 pm

    Yes, that’s initially what I did, copied it as flat text and added the jsx extension, I can see it in my list of scripts inside AE but it returns the error immediately after I try to run it. I then tried open the script editor from within AE, after you mentioned that, assuming it would probably fix/complete whatever is missing in order to have it run in Ae but I can’t launch it anymore.

    Adobe moved to a thing called VS Code now in replacement of EXtendscript, but it’s waaaaaaaaaaaaaaay beyond my abilities to even understand what’s going on.

    If you have time to send the link it would be appreciated but if not don’t sweat it, I’ll manage freezing the layers by hand.

    Thanks.

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