Forum Replies Created

Page 2 of 3
  • James Ronan

    September 13, 2018 at 9:55 am in reply to: Using object position to drive counter expressions.

    Okay I had a little crack at it this morning, maybe theres a better way, but here’s where I’m at. This should allow you to animate the cursor along the x axis and it will display the current value on a text layer.

    The rA variable is just an example array of stored values. 0,24,37,2,10,80,60,55,80,23
    You can update that to read the data from a spreadsheet row or JSON file or w/e you choose.

    On your cursor layer set two keyframes, the start position and end position and apply this expression to the source text property of your text layer. No easing though!


    var rA = [0,24,37,2,10,80,60,55,80,23]; // result Array
    var cursor = thisComp.layer("cursor"); // layer you choose to animate the x axis position
    var xPos = cursor.position[0];
    var startPos = cursor.position.key(1).value[0];
    var endPos = cursor.position.key(2).value[0];
    var aryN = linear(xPos,startPos,endPos,0,rA.length);
    var aryNPrev = Math.floor(aryN);
    var aryNNext = Math.ceil(aryN);
    try{
    txt = linear(aryN,aryNPrev,aryNNext,rA[aryNPrev],rA[aryNNext]);
    txt.toFixed(2);
    } catch (err){
    rA[rA.length-1].toFixed(2)
    }

  • James Ronan

    September 12, 2018 at 2:45 pm in reply to: Using object position to drive counter expressions.

    How would I modify the expression to target the X slider position of a null that the cursors X position is parented too
    Update the c variable to look at what ever you’re using to move the curser. This could be either the null or a slider.

    e.g. if you’ve linked it to a slider:
    c = thisComp.layer(“LAYER NAME”).effect(“Slider Control”)(“Slider”).value;

    It’s possible if you update the linear expression with the y axis. But that will involve moving your curser that way too.

    It gets more complicated if you want to only move your curser along the x axis and not the y.

  • Maybe something like this, on the opacity layer of the White Solid.


    try{
    comp("Precomp 001").layer("Black Solid");
    0
    }catch(err){
    100
    }

  • James Ronan

    September 11, 2018 at 9:08 am in reply to: Using object position to drive counter expressions.

    I think your looking for the linear function. Here’s an example for the weeks

    Apply this expression to the sourceText property of a text layer:


    weekStart = 0;
    weekEnd = 20;

    posStart = 0;
    posEnd = thisComp.width;

    c = thisComp.layer("curser").transform.position[0];
    week = linear(c,posStart,posEnd,weekStart,weekEnd);

    Math.round(week);

    This will update the week as the curser moves along the x-axis from one side of the comp to the other.

    Hope that helps!

  • Check out a script called WayFinder on aescripts, it allows you to attach and guide artwork along shapes layers.

    https://aescripts.com/wayfinder/

  • James Ronan

    September 6, 2018 at 2:45 pm in reply to: Custom speeds when easing via expression ease(t,a,b,x,y)

    This was my approach when doing something similar… Maybe it will help you get started. It doesn’t have custom controls for velocity though.

    Add as an expression on the position property of a layer. It will move the layer 500px along the x axis between 1 – 2 seconds.


    function easeInOutCubic(t) { return t<.5 ? 4*t*t*t : (t-1)*(2*t-2)*(2*t-2)+1 };

    startVal = 0;
    endVal = 500;
    startDur = 1;
    endDur = 2;

    t = linear(time,startDur,endDur,0,1);
    e = easeInOutCubic(t);
    x = linear(e,0,1,startVal,endVal);

    [x, value[1]];

    I took the easeInOutCubic function from this website which has a variety of easing functions:
    https://gist.github.com/gre/1650294

    Hope that helps

  • James Ronan

    September 1, 2018 at 5:22 pm in reply to: Position changes on the scale of the layer

    If your circle layer has it’s anchor point centered you could try this expression on it’s position property:


    L = thisComp.layer("bar");
    r = L.sourceRectAtTime(time,false)
    L.toWorld([r.width/2,r.top]);

  • James Ronan

    August 2, 2018 at 2:31 pm in reply to: selectLayers script

    Ah, hadn’t seen your later messages.
    No worries, glad you got it working!

  • James Ronan

    August 2, 2018 at 2:27 pm in reply to: selectLayers script

    Hey Scott.

    Here’s a rough example of a window with 3 buttons, that adds or replaces the fill effect across all selected layers:

    Hope that helps!

    var win = new Window('dialog', "Test");

    var btnAry = [];
    var colAry =
    [
    [1, 0, 0],
    [0, 1, 0],
    [0, 0, 1]
    ];

    var clickHandlerFill = function(i) {

    return function() {

    app.beginUndoGroup("AddEffect");
    var curItem = app.project.activeItem;
    var selectedLayers = curItem.selectedLayers;
    var curRem, curLayer;

    for (var j = 0; j < selectedLayers.length; j++) {

    try {
    curRem = selectedLayers[j].effect.property("Fill").remove();
    curLayer = selectedLayers[j].Effects.addProperty("ADBE Fill")("Color").setValue(colAry[i]);
    }
    catch (err) {
    curLayer = selectedLayers[j].Effects.addProperty("ADBE Fill")("Color").setValue(colAry[i]);
    }
    }

    app.endUndoGroup();

    };
    }

    // Create buttons and assign clickHandler
    for (var i = 0; i < 3; i++) {

    btnAry[i] = win.add('button', undefined, i);
    btnAry[i].onClick = clickHandlerFill(i);

    }

    win.show();

  • James Ronan

    August 1, 2018 at 4:38 pm in reply to: selectLayers script

    I’m not 100% following your code, but the “curItem.selectedLayers[0]” parts will mean it will only affect the first layer selected.

    You could try adding a for loop, going through your selected layers to affect all of them:

    var selectedLayers = curItem.selectedLayers;
    var curRem, curLayer;

    for (var j = 0; j < selectedLayers.length; j++) {

    try {
    curRem = selectedLayers[j].effect.property("Fill").remove();
    curLayer = selectedLayers[j].Effects.addProperty("ADBE Fill")("Color").setValue(pcolor[i]);
    }
    catch (err) {
    curLayer = selectedLayers[j].Effects.addProperty("ADBE Fill")("Color").setValue(pcolor[i]);
    }
    }

    Hope that helps!

Page 2 of 3

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