Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Creating visual smears using expressions. Help me put it all together!

  • Creating visual smears using expressions. Help me put it all together!

  • Ryan Hauser

    January 13, 2023 at 6:51 pm

    I’ve been fiddling with expressions for the last 3 hours, and I’m so close I can feel it. But I’m not quite there yet. Perhaps I can get help here?

    I’m attempting to define the area of a motion smear using the createPath function.

    In the first photo, you will see I have a stick with two nulls on each end. Those are the nulls I want to use to get the smear’s information — I want to get X number of each null’s coordinates over Y period of time. Then I want to use those coordinates as the blueprint for the createPath – Stepping first over the top null’s returned coordinates over time, then backwards over the bottom null’s returned coordinates over time. The second photo is a picture of my code. Hopefully you can at least see what I’m attempting to do, even though the code itself doesn’t actually achieve what I want.

    The third photo is a picture of what, when the expression is working, the result should probably look like.

    Please let me know if I can provide any clarification for you! I feel as though I’m extremely close, but just not quite there. Any and all help is appreciated!

  • Ryan Hauser

    January 13, 2023 at 9:24 pm

    I’ve been at this still… I’m currently just trying to get the top arc to appear using the createPath function. From everything I’ve read, this looks like it should at least do SOMETHING, but no matter what I change nothing appears on screen. I feel as though my loop isn’t actually adding anything to myArray. If I set a value to myArray manually, I see a line appear proving to me that there’s at least 2 values in the myArray array. but the moment I get rid of the manually coded value, the line disappears which suggests there aren’t any values actually stored within the array. Thoughts?

  • Dan Ebberts

    January 13, 2023 at 10:57 pm

    Your code, entered like this:

    topArc = effect("Top Arc -> Value @ Time")("Point");
    pts = effect("Arc Resolution")("Slider")
    timeScale = effect("Timescale")("Slider");
    myArray = [];
    for (i = 0; i < pts; i++){
    myArray[i] = topArc.valueAtTime(i*timeScale);
    }
    createPath(myArray,[],[],true)

    works for me. I had Arc Resolution set to 10, Timescale set to .1, and I animated the Point Control over the period from 0 to 1 second.

  • Ryan Hauser

    January 13, 2023 at 11:45 pm

    I’m so mad right now. After I had made the above post, I had figured out that I DID have it right like you demonstrated just now. So the top arc worked, and I also got the bottom arc working. I was just having an issue; I needed the bottom arc to be read backwards otherwise the shape made an “X” shape in the middle since the bottom row was also read “left to right”. While attempting to fix it, I accidentally crashed AE and as it turns out I hadn’t saved the project. I started over. I got the top arc working again, and now I can’t get the bottom arc working anymore. I cannot for the life of my figure out what’s wrong with this, or why I was able to get it working the first time. I don’t even know anymore. Here’s a screenshot with everything relevant to the project, and here’s a copy-paste of the main code. I appreciate the help, Dan. Lifesaver as always.

    //Bring in data
    var topArcPos = effect("Top Arc Position")("Point");
    var botArcPos = effect("Bottom Arc Position")("Point");
    var pts = effect("Arc resolution")("Slider");
    var timeMult = effect("Timescale")("Slider");
    //Create containers; set base values
    var myArray = [];
    var myArray2 = [];
    var i;
    var i2;
    //Add values to Array (left to right)
    for (i=0;i<pts;i++){
    myArray[i] = topArcPos.valueAtTime(time-(i*timeMult));
    }
    //Add values to Array2 (left to right)
    for (i2=0;i2<pts;i2++){
    myArray2[i2] = botArcPos.valueAtTime(time-(i*timeMult));
    }
    //Flip myArray2
    myArray2.reverse();
    //Join myArray2, now reversed, to the end of myArray
    myArray.concat(myArray2);
    createPath(points = myArray, inTangents = [], outTangents = [], isClosed = true)
  • Dan Ebberts

    January 14, 2023 at 1:01 am

    concat() doesn’t change either array, but I was able to get this to work:

    var topArcPos = effect("Top Arc Position")("Point");
    var botArcPos = effect("Bottom Arc Position")("Point");
    var pts = effect("Arc resolution")("Slider");
    var timeMult = effect("Timescale")("Slider");
    //Create containers; set base values
    var myArray = [];
    var myArray2 = [];
    var myNewArray = [];
    var i;
    var i2;
    //Add values to Arrays
    for (i=0;i<pts;i++){
    myArray[i] = topArcPos.valueAtTime(i*timeMult);
    myArray2[i] = botArcPos.valueAtTime(i*timeMult);
    }
    //Flip myArray2
    myArray2.reverse();
    //Join myArray2, now reversed, to the end of myArray
    myNewArray = myArray.concat(myArray2);
    createPath(points = myNewArray, inTangents = [], outTangents = [], isClosed = true)

    I changed the valueAtTime stuff to what I had before, because I couldn’t figure out what you were doing there, but this should get you closer.

  • Dan Ebberts

    January 14, 2023 at 1:37 am

    Another I noticed was that in your 2nd loop, you referenced i instead of i2, so that was probably one issue.

  • Ryan Hauser

    January 14, 2023 at 2:19 am

    Ebberts, you’ve done it again. I’ve attached a gif below, of the arc script in action. Maybe it’ll play here, I’m not sure.

    I’m happy to have the script working, but do you think you can explain to me why your script (with minor edits) works flawlessly:

    var topArcPos = effect("Top Arc Position")("Point");

    var botArcPos = effect("Bottom Arc Position")("Point");

    var pts = effect("Arc resolution")("Slider");

    var timeMult = effect("Timescale")("Slider");

    //Create containers; set base values

    var myArray = [];

    var myArray2 = [];

    var myNewArray = [];

    var i;

    var i2;

    //Add values to Arrays

    for (i=0;i<pts;i++){

    myArray[i] = topArcPos.valueAtTime(time-i*timeMult);

    myArray2[i] = botArcPos.valueAtTime(time-i*timeMult);

    }

    //Flip myArray2

    myArray2.reverse();

    //Join myArray2, now reversed, to the end of myArray

    myNewArray = myArray.concat(myArray2);

    createPath(points = myNewArray, inTangents = [], outTangents = [], isClosed = true)

    And mine, when I try to build the same thing, returns an error that says “Error: Error: createPath requires the points, inTangents, and outTangents to contain at least 1 point, and all be the same size”? I’ve also made the array dead-simple in my attempt to rule out weird stuff with the more complicated things in the working version. It kicked back the same error regardless.


    var arcTop = effect("Arc Top toComp")("Point");

    var arcBot = effect("Arc Bottom toComp")("Point");

    var pts = effect("Points")("Slider");

    var timeMult = effect("timeMult")("Slider");

    //Create containers; set base values

    var myArray1 = [];

    var myArray2 = [];

    var myNewArray = [];

    var i;

    //Run loop to build both arrays

    for (i=0;i<pts;i++) {

    myArray1[i] = [i,i];

    myArray2[i] = [i,i];

    }

    myNewArray = myArray1.concat(myArray2)

    createPath(points = myNewArray, inTangents = [], outTangents = [], isClosed = true)

    I feel like Creed in The Office being presented two identical pictures and then being asked to find the difference. Clearly there is one, but I can’t for the life of me find it.

    Again Ebberts, you’re a life-saver.

  • Dan Ebberts

    January 14, 2023 at 4:06 am

    You would get that message if your pts slider was set to 0;

Viewing 1 - 8 of 8 posts

Log in to reply.

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