Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Quick expression problem with Levels Adjustment

  • Quick expression problem with Levels Adjustment

    Posted by Bryan Woods on January 25, 2013 at 7:45 pm

    I’ve got a little fire I need to put out, so any quick responses to this would be MOST appreciated!

    I thought I would be able to easily control the levels adjustment effect with the dynamic fade expression, and just modify values, but it keeps giving me the inverse of what I want. I’m using a Levels adjustment (The individual controls version), and applying the below expression to the Output Black parameter. This fades the clip up to white, instead of fading down from white. I can’t figure out how to invert it! It seems like it’d be so simple, but its proving to be quite a problem. Any ideas?

    transition = 20; // transition time in frames

    if (marker.numKeys<2){
    tSecs = transition / ( 1 / thisComp.frameDuration); // convert to seconds
    linear(time, inPoint, inPoint + tSecs, 0, 2.5) - linear(time, outPoint - tSecs, outPoint, 0, 2.5)
    }else{
    linear(time, inPoint, marker.key(1).time, 0, 2.5) - linear(time, marker.key(2).time, outPoint, 0, 2.5)
    }

    Also a quick note: I have tried swapping values, and I get a negative (literally) effect instead of positive.

    Bryan Woods replied 13 years, 6 months ago 2 Members · 7 Replies
  • 7 Replies
  • Bryan Woods

    January 25, 2013 at 7:56 pm

    Nevermind! Figured it out! Code below for any future reference:

    Apply to Ouput Black on Levels effect (individual controls version):

    //Autofade: Add to opacity

    transition = 20; // transition time in frames

    if (marker.numKeys<2){
    tSecs = transition / ( 1 / thisComp.frameDuration); // convert to seconds
    linear(time, inPoint, inPoint + tSecs, -1, -2.5) + linear(time, outPoint - tSecs, outPoint, 2.5, 4)
    }else{
    linear(time, inPoint, marker.key(1).time, -1, -2.5) + linear(time, marker.key(2).time, outPoint, 2.5, 4)
    }

  • Dan Ebberts

    January 25, 2013 at 7:58 pm

    I’d do it like this:


    transition = 20;
    if (marker.numKeys<2){
    tSecs = framesToTime(transition);
    if (time < (inPoint + outPoint)/2)
    linear(time, inPoint, inPoint + tSecs,2.5,0)
    else
    linear(time, outPoint - tSecs, outPoint,0,2.5);
    }else{
    if (time < (inPoint + outPoint)/2)
    linear(time, inPoint, marker.key(1).time,2.5,0)
    else
    linear(time, marker.key(2).time, outPoint, 0, 2.5);
    }

    Dan

  • Bryan Woods

    January 25, 2013 at 8:31 pm

    Ah, that is a bit nicer. I’ll take that into consideration.

    Another issue I’m having maybe you can point out the issue. I’m trying to roll this into a script, and I’m having a hard time targeting the “Output Black” sub property of the levels control. At line 23 I get an error stating “Null is not an object”.

    //Set Undo Group

    {
    app.beginUndoGroup("SlideShow_FX");

    //Define project and active items
    var proj = app.project;
    var theComp = proj.activeItem;
    var selectedLayers = theComp.selectedLayers;

    //For every layer selected...
    for (var i = 0; i < selectedLayers.length; i++) {
    var myLayer = selectedLayers[i];
    var levelsAdjust = myLayer.Effects.addProperty("Levels (Individual Controls)");
    myLayer.property("Levels (Individual Controls)")("Output Black").expression = "1"; //value of 1 is acting as debug. I'll put the actual expression in later
    }
    app.endUndoGroup();

    }

  • Dan Ebberts

    January 25, 2013 at 10:53 pm

    Try changing that line to this:

    myLayer.property(“Effects”)(“Levels (Individual Controls)”)(“Output Black”).expression = “1”;

    Dan

  • Bryan Woods

    January 26, 2013 at 12:09 am

    Thanks Dan. That’s what I was missing; (“Effects”). Forgot that everything was in a master sub menu.

    On a different topic, would you happen to know how to set an effect’s window to be closed instead of twirlled open in the effects window? This script is adding an effect and some sliders, and I don’t want the effect to be open (because it takes up a lot of space visually). I’ve seen others do it, but I have no clue how to access that kind of attribute. I’m sure its some boole operation, but I have no idea what the syntax would be for it.

  • Dan Ebberts

    January 26, 2013 at 12:56 am

    If controlling the twirl gizmos is possible with scripting, I would love to know how to do it. Are you sure you’ve seen it?

    Dan

  • Bryan Woods

    January 26, 2013 at 4:01 am

    I could have sworn I’ve seen it done before. Some kind of multi effect from a script I used a long time ago plucked from AEscripts. I thought maybe plexus did this, but I just checked and all the effects palettes are open when they’re created. I also checked the CS6 expressions guide pdf and no mention of anything like that in there. I can’t believe they wouldn’t put an option to set the state of the twirl down gizmo… 🙁 Maybe Todd would know?

    By the way, thank you yet again for all your help. I really do appreciate all the effort you put into helping me and so many others on this forum.

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