Forum Replies Created

Page 52 of 65
  • Andrei Popa

    March 19, 2019 at 12:51 pm in reply to: Trigger source text change with markers

    I am not completely sure what you want to achieve, but maybe this will help. This changes the source text to the layer name except the first 3 chars. Decreases index by one each time it passes a marker and starts with the last layer(before the first marker). No marker means that it takes the last layer.

    //set variables
    sc = comp("otherComp"); // source comp
    lc = sc.numLayers; // layer count of source comp
    m = thisLayer.marker;
    idx = lc; // layer index;
    m = thisLayer.marker;

    //marker triggers
    if (m.numKeys > 0) {
    n = m.nearestKey(time).index;
    if (time < m.key(n).time) n--;
    idx = lc - n;
    sc.layer(idx).name.substr(3, sc.layer(idx).name.length);
    } else {
    sc.layer(idx).name.substr(3, sc.layer(idx).name.length);
    }

    Andrei
    My Envato portfolio.

  • Andrei Popa

    March 7, 2019 at 2:57 pm in reply to: Is it possible to run a script on save command

    I think the best you can do is install nodeJS and gulp. And with gulp you can automate some processes.

    You can make it do something anytime you save a file. So you put a “watch” on your script and tell gulp to run it maybe via batch command. But this requires you to keep the node command prompt running.

    So i’d say that this is possible, but a bit tricky to organize.

    Andrei
    My Envato portfolio.

  • Your code is rather complicated. If you have a random number and want to round it to x decimals, just go

    var myNumber = someRandomNumber;
    var multiplicator = Math.pow(10,x);
    Math.round(myNumber*multiplicator)/multiplicator;

    To simple things up, multiplicator is 10 if you want a decimat, 100 if you want 2 etc.

    Andrei
    My Envato portfolio.

  • Andrei Popa

    March 2, 2019 at 6:41 am in reply to: Object isn’t attaching to the anchor point

    What i would do would be attaching this to the anchor point of the rectangle shape

    temp = thisLayer("Contents")("Rectangle 1")("Contents")("Rectangle Path 1")("Size")[0]/2;
    [temp, value[1]]

    This way, it is fixed on the right side. Then just move it near the white line and it should stay there.

    Andrei
    My Envato portfolio.

  • Andrei Popa

    February 25, 2019 at 2:23 pm in reply to: Parent a especific keyframe

    Try this

    thisComp.layer("B")("ADBE Transform Group")("ADBE Scale").key(2).value

    Andrei
    My Envato portfolio.

  • Andrei Popa

    February 25, 2019 at 2:17 pm in reply to: Search for a layer in comp

    You just need to go through the selection and apply this function to each composition. Replace the “XYZ” in the second row with the name of your choice. This will also skip anything selected that is not a composition and allert you about it.

    for (var i=0; i< app.project.selection.length; i++){
    searchLayer("XYZ",app.project.selection[i]);
    }

    function searchLayer(layerName, myComposition){
    if(myComposition instanceof CompItem){
    for (var i = 1; i<= myComposition.numLayers;i++){
    if (myComposition.layer(i).name == layerName){
    myComposition.layer(i).remove();
    return null;
    }
    }
    //return myComposition.layers.addText(layerName);
    }else{
    alert(myComposition.name +" is not a composition. Will skip it.");
    }
    }

    Andrei
    My Envato portfolio.

  • Andrei Popa

    February 21, 2019 at 9:19 am in reply to: what drives the expression to loop ?

    TIME. I remember having the same problem the first time i saw an expression. I was like how the hell does that thing iterate. It’s the time. Each frame, the time is different. And in order to make it an integer(time is float), you use Math.floor. Feel free to ask further explanations if you did not understand it.
    You can write this expression to the source text of a text layer to see exactly how it works.

    "time is:"+time+"\nand Math.floor(time) is:"+Math.floor(time)

    Andrei
    My Envato portfolio.

  • Andrei Popa

    February 15, 2019 at 2:33 pm in reply to: sourceRectAtTime expression

    Maybe something like this
    width1 = thisComp.layer("TOP LINE TEXT LONGER STILLER").sourceRectAtTime(time,true).width;
    width2 = thisComp.layer("TEXT 2").sourceRectAtTime(time,true).width;
    x = Math.max(width1, width2);
    y = 104;
    [x , y]

    Andrei
    My Envato portfolio.

  • Andrei Popa

    February 15, 2019 at 6:31 am in reply to: What is faster? Time remapping or valueAtTime?

    Thank you guys. This is very helpful to me.

    Andrei
    My Envato portfolio.

  • Andrei Popa

    February 9, 2019 at 7:52 am in reply to: Script runs a function that doesn’t exist anymore

    Once you run a script, all the variables that are global are saved in memory until you restart your engine(AE here, but could be extendscript, illustrator etc). In order to not have this problem, you need to store your variables locally. To do that, the best practice in my opinion is use this kind of code as a frame for yours:

    (function myScript(thisObj){

    //here you write your code

    })(this)

    This function calls on itself, and all the variables you have are stored inside it. So when it stops running, you have no variable “leftover”.
    As a fun fact. You can actually use a variable from a script into another script if it is stored globally.

    I hope i answered your question.

    Andrei
    My Envato portfolio.

Page 52 of 65

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