Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions setValue() to levels effect not returning expected value

  • setValue() to levels effect not returning expected value

    Posted by Jeremy Dance on July 28, 2017 at 4:28 pm

    New to scripting here…
    I’m trying to add a levels effect to a composition and set the value for “Input Black” and “Input White”

    However, when I run the script in After effects I see values thousands above what I put in.

    Here is my code:
    myComp.property(“Effects”).property(“Levels”).property(“Input Black”).setValue(118);
    myComp.property(“Effects”).property(“Levels”).property(“Input White”).setValue(141);

    The value I get in After Effects are:
    Input Black = 30090
    Input White = 35955

    On my last line of my code, I even added an alert to tell me the value of input white.
    alert( . . . (“Input White”).value);
    It said the value for input white was 141 so I know nothing later in the code is changing it.

    What am I not understanding?

    myComp.property("Effects").property("Levels").property("Input Black").setValue(118);
    myComp.property("Effects").property("Levels").property("Input White").setValue(141);

    Jeremy Dance replied 8 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    July 28, 2017 at 6:09 pm

    Colors need to be normalized to be between zero and one. So this should work to get 141:

    myComp.property(“Effects”).property(“Levels”).property(“Input White”).setValue(141/255);

    Dan

  • Jeremy Dance

    July 28, 2017 at 11:18 pm

    Thanks!

    I’m curious as to where in the documentation I could learn more about this. I’m not sure what words to search in the scripting guide to find it. I’m sure I’ll run into it more.

    For example, I couldn’t get the number I wanted for opacity until I multiplied it by (100/255). What causes that strange behavior?

    myfxComp.property(“Effects”).property(“Drop Shadow”).property(“Opacity”).setValue(43*255/100);
    The above line sets the percentage to 43%

    myComp.property("Effects").property("Drop Shadow").property("Opacity").setValue(43*255/100);

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