Forum Replies Created

Page 83 of 1081
  • Dan Ebberts

    July 5, 2022 at 3:17 pm in reply to: Checkbox Control with more complex expression.

    <div>This assumes that you’re using 2 keyframes to get your letters on screen, and gives the overshoot 2 seconds to settle out. If your conditions are different, you’ll need to adjust the second line:</div>

    val = value;
    if ((numKeys >= 2 && (time < key(2).time + 2)) || numKeys > 0){
    n = nearestKey(time).index;
    if (key(n).time > time) n--;
    t = n > 0 ? time - key(n).time : 0;
    if (n > 0 && t < 1){
    v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
    amp = .02;
    freq = 3.0;
    decay = 5.0;
    val = value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
    }
    }
    val

  • Dan Ebberts

    July 2, 2022 at 5:53 pm in reply to: test

    test 3

    var preset1path = "/c/test/preset1.ffx";
    var preset2path = "/c/test/preset2.ffx";
    var myComp, mySelected;
    for (var i = 1; i <= app.project.numItems; i++){
    myComp = app.project.item(i);
    if (myComp instanceof CompItem){
    mySelected = myComp.selectedLayers;
    for (var j = 0; j < mySelected.length; j++){
    mySelected[j].selected = false;
    }
    myComp.layer(1).selected = true;
    myComp.layer(1).applyPreset(File(preset1path));
    myComp.layer(1).selected = false;
    myComp.layer(2).selected = true;
    myComp.layer(2).applyPreset(File(preset2path));
    }
    }
  • I’ll try that–thanks!

  • The basic structure could be something like this, but I’d probably add some additional checks to make sure the comp has the layers you’re expecting, that they’re not locked, etc.

    var preset1path = "/c/test/preset1.ffx";

    var preset2path = "/c/test/preset2.ffx";

    var myComp, mySelected;

    for (var i = 1; i <= app.project.numItems; i++){

    myComp = app.project.item(i);

    if (myComp instanceof CompItem){

    mySelected = myComp.selectedLayers;

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

    mySelected[j].selected = false;

    }

    myComp.layer(1).selected = true;

    myComp.layer(1).applyPreset(File(preset1path));

    myComp.layer(1).selected = false;

    myComp.layer(2).selected = true;

    myComp.layer(2).applyPreset(File(preset2path));

    }

    }

  • BTW, how do you post your code here so that you don’t get an extra blank line between lines with text? I’ve never been able to figure that out.

  • If you’re ok with repeating what’s in the shuffled array, you could just do some modulo math on whatever you’re using for an array index:

    idx%array.length
  • Dan Ebberts

    July 1, 2022 at 3:13 pm in reply to: Link a work area to a slider

    It would depend on how you have your out animation set up, but you could do something like this:

    t = Math.max(time - thisComp.layer("CTRL").effect("DURATION IN SEC")("Slider"),0);

    valueAtTime(t)

  • What I would do would be to put all your swatch choices into an array, then shuffle the array, and then read them out sequentially. You’d have to work this into your code, but shuffle part might look like this:

    function shuffle(a) {

    seedRandom(index,true);

    for (i = a.length - 1; i > 0; i--) {

    j = Math.floor(random() * (i + 1));

    temp = a[i];

    a[i] = a[j];

    a[j] = temp;

    }

    }

    cFrom = 1;

    cTo = 9;

    array = [];

    for (i = cFrom; i <= cTo; i++){ // build the array

    array.push(i);

    }

    shuffle(array);

  • I like that better, because it should still work, even if they fix the bug. Good sleuthing!

  • Scripting does have a command specifically for creating box text, so you could do something like this to create the text and center the anchor point within the resulting text (which will be centered within the comp):

    var myComp = app.project.activeItem;

    var myTextLayer = myComp.layers.addBoxText([300,500]);

    var mySourceText = myTextLayer.property("ADBE Text Properties").property("ADBE Text Document");

    var myTextDoc = mySourceText.value;

    myTextDoc.text = "This is a line of text for my new text box.";

    myTextDoc.justification = ParagraphJustification.CENTER_JUSTIFY;

    mySourceText.setValue(myTextDoc);

    var myRect = myTextLayer.sourceRectAtTime(0,false);

    var newAP = [myRect.left + myRect.width/2, myRect.top + myRect.height/2];

    myTextLayer.property("Anchor Point").setValue(newAP);

Page 83 of 1081

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