Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Using a Point Controller instead of 2 separate sliders giving me an error

  • Using a Point Controller instead of 2 separate sliders giving me an error

    Posted by Mike Foran on November 11, 2022 at 10:58 pm

    I have been messing around with Dan Ebbert’s frequency expression to create an oscillating position for objects. I set up the expression so X and Y had independent frequencies. It works great if I pull my ‘freq’ variables from sliders. But in an effort to consolidate controllers, I tried to replace the two X and Y frequency sliders with a Point Controller, thinking I could pull the frequency values from that. But when swap the slider for one of the point values, the expression breaks with a “couldn’t turn result into a numeric value’ error. I can’t figure out why it’s not a number. Here’s the expression:

    // Calculate X Frequency
    xfreq = effect(“Point Control”)(“Point”)[0];
    amp = effect(“X_Amp”)(“Slider”);
    n = xfreq.numKeys;
    if (n > 0 && xfreq.key(1).time < time){
    accum = xfreq.key(1).value*(xfreq.key(1).time – inPoint);
    for (i = 2; i <= n; i++){
    if (xfreq.key(i).time > time) break;
    k1 = xfreq.key(i-1);
    k2 = xfreq.key(i);
    accum += (k1.value + k2.value)*(k2.time – k1.time)/2;
    }
    accum += (xfreq.value + xfreq.key(i-1).value)*(time – xfreq.key(i-1).time)/2;
    }else{
    accum = xfreq.value*(time – inPoint);
    }
    x = value[0] + amp*Math.sin(accum*Math.PI*2);

    // Calculate Y Frequency
    yfreq = effect(“Point Control”)(“Point”)[1];
    amp = effect(“Y_Amp”)(“Slider”);
    n = yfreq.numKeys;
    if (n > 0 && yfreq.key(1).time < time){
    accum = yfreq.key(1).value*(yfreq.key(1).time – inPoint);
    for (i = 2; i <= n; i++){
    if (yfreq.key(i).time > time) break;
    k1 = yfreq.key(i-1);
    k2 = yfreq.key(i);
    accum += (k1.value + k2.value)*(k2.time – k1.time)/2;
    }
    accum += (yfreq.value + yfreq.key(i-1).value)*(time – yfreq.key(i-1).time)/2;
    }else{
    accum = yfreq.value*(time – inPoint);
    }
    y = value[1] + amp*Math.sin(accum*Math.PI*2);

    [x,y];

    Tomas Bumbulevičius replied 3 years, 6 months ago 3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    November 11, 2022 at 11:26 pm

    I think the problem might be that when xfreq and yfreq point to individual x and y values of the point control, xfreq.numKeys and xfreq.key() no longer make sense.

  • Mike Foran

    November 11, 2022 at 11:32 pm

    Ah that makes sense. Thanks Dan.

  • Tomas Bumbulevičius

    November 12, 2022 at 10:50 am

    As this is about Point Controllers as well, does anyone noticed that if you change composition size, even though point controllers are not connected with any width/height properties, they change their values based on the new ratio of the comp size?

    So lets say you have point controller set to [1,1] and for simplicity have comp size of [1000,1000]

    If comp size is changed to [1000,2000] point control becomes [1,2]. This is not what I could have expected, thus its something to be aware of when using Point Controls – unless its a bug in 2023 version

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