Forum Replies Created

Page 29 of 65
  • Andrei Popa

    May 21, 2020 at 3:54 pm in reply to: Use Wiggle to blink characters in a line of text

    Make a text layer. Add this expression to the text property;


    var numChars = 20;
    var solution = '';
    for(var i=0; i< numChars; i++){
    solution+=Math.round(random())
    }
    solution

    Andrei
    My Envato portfolio.

  • Andrei Popa

    May 19, 2020 at 12:06 pm in reply to: Enabling/Disabling Layers with Layer Name

    Please be specific on what you want the script to do.

    You want it to work only on video footage? Or maybe also on different layers?
    Only on the active composition or the entire project?
    And exactly like this one, treat them by the last 2 characters of the name?

    Andrei
    My Envato portfolio.

  • Andrei Popa

    May 18, 2020 at 8:16 am in reply to: Function works on dialog but not on a palette

    Off topic: Please don’t start your function name with capital letters.

    On topic:

    Idk if the problem is the one specified by Thomas. But if so, why don’t pass the composition as a parameter in your function?
    Something like

    function detect(comp) {
    var videoLayer = comp.selectedLayers[0];
    var time = comp.time;
    var frame = Math.round(time / comp.frameDuration);
    var opacityLevel = videoLayer.property("Transform").property("Opacity");
    var threshold = 48.0;

    above = false;
    while (frame <= 100) {
    t = frame * comp.frameDuration;
    if (above) {
    if (opacityLevel.valueAtTime(t, true) != threshold) {
    frame++;
    above = false;
    }
    } else if (opacityLevel.valueAtTime(t, true) == threshold) {
    above = true;
    var myMarker = new MarkerValue("Mark");
    videoLayer.property("Marker").setValueAtTime(t, myMarker);
    }
    frame++;
    }
    }
    //and call it like this on the onClick event of the button
    detect(app.project.activeItem);

    I need to see the entire code and test it in order to see the problem, because it’s not that obvious.
    If you can share your code or file, I could be more explicit.

    Andrei
    My Envato portfolio.

  • Andrei Popa

    May 16, 2020 at 9:49 am in reply to: Values of array

    I don’t have an Object.keys on my version of after effects. I use AE 2020.
    It may be that you have a different version or maybe you have some sort of library that extendet “Object” with a .keys function. You can check that by either

    alert(Object.toSource())

    or

    $.writeln(Object.toSource())

    When i run either one of these 2 functions, i only get (function Object() { [native code] } ), which means that my Object class does not have any new functions added to it.

    Andrei
    My Envato portfolio.

  • Andrei Popa

    May 14, 2020 at 3:35 pm in reply to: Automating Insertion of External Sound Clips

    I had a typo


    var myFile = File.openDialog("Select your source file");
    if (myFile != null && myFile.open("r")) {
    var myString = myFile.read();
    myFile.close();
    }

    var arrayOfFileNames = myString.split("\n");

    for (var i = 0; i < arrayOfFileNames.length; i++) {
    mySoundLayer = addFileToProject(new File(myFile.path + "/" + arrayOfFileNames[i]), app.project.activeItem);
    mySoundLayer.startTime = i * 10;
    }

    function addFileToProject(myFile, myComp) {
    var myImportOptions = new ImportOptions();
    myImportOptions.file = myFile;
    var fileAsItem = app.project.importFile(myImportOptions);
    if (myComp != null) {
    return myComp.layers.add(fileAsItem);
    }
    return fileAsItem;
    }

    Andrei
    My Envato portfolio.

  • Andrei Popa

    May 14, 2020 at 3:35 pm in reply to: Automating Insertion of External Sound Clips

    Haven’t test this but it should work. Run this with the target composition opened. Also, the sound files must be in the same folder as your text file.


    var myFile = File.openDialog("Select your source file");
    if (myFile != null && myFile.open("r")) {
    var myString = myFile.read();
    myFile.close();
    }

    var arrayOfFileNames = myString.split("\n");

    for (var i = 0; i < arrayOfFileNames.length; i++) {
    mySoundLayer = addFileToProject(new File(myFile.path + "/" + arrayOfFileNames[i]), aoo.project.activeItem);
    mySoundLayer.startTime = i * 10;
    }

    function addFileToProject(myFile, myComp) {
    var myImportOptions = new ImportOptions();
    myImportOptions.file = myFile;
    var fileAsItem = app.project.importFile(myImportOptions);
    if (myComp != null) {
    return myComp.layers.add(fileAsItem);
    }
    return fileAsItem;
    }

    Andrei
    My Envato portfolio.

  • Andrei Popa

    May 14, 2020 at 3:15 pm in reply to: Values of array

    That is an object. An array looks like this myArray = [1,2,3] and you access its values like this myArray[1].
    How do you want to get the values of your object? As a string in this format “1,2”? If yes, try this:

    function getValues(object){
    var values = [];
    for (var i in object) {
    values.push(object[i]);
    }
    return values.join(",");
    }

    alert(getValues(myArray));

    Andrei
    My Envato portfolio.

  • Andrei Popa

    May 13, 2020 at 8:56 am in reply to: How to use length in if statement

    I think you also need to give it a value if the distance is greater.


    target=thisComp.layer("Circle");
    s = sub(target.transform.position,transform.position);
    if(length(s) <= 100){
    lookAt(target.transform.position,transform.position);
    }else{
    value
    }

    Andrei
    My Envato portfolio.

  • Andrei Popa

    May 12, 2020 at 7:23 pm in reply to: Maximum number of points in a path

    Hey. I replaced pas with 0.1. Same result, but a lot heavier on rendering.
    I use after effects 2020, 64 gigs of ram and Ryzen 7 3700x.
    The layer is selected so you can see that it goes out of screen.

    Andrei
    My Envato portfolio.

  • I guess your only mistakes are the square brackets. You don’t need those, since the link to the color returns an array.

    Col=thisComp.layer("Null 42").effect("Slider Control")("Slider");
    color1=thisComp.layer("Null 42").effect("Color 1")("Color");
    color2=thisComp.layer("Null 42").effect("Color 2")("Color");
    linear (Col,0,100,color1,color2)

    Andrei
    My Envato portfolio.

Page 29 of 65

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