Forum Replies Created

Page 19 of 32
  • With this expression, the entries of the array ‘strings’ are all of the formm “something+[up/down/left/right]”, except maybe the very last one. So for that last entry you have to check again:

    N = strings.length;
    all entries: strings[n] (n=0,…., N-2) have one of your direction patterns at the end;
    the last entry (which is strings[0] if N===1) can be an exception:

    if (strings[N-1].match(/\[(up|down|left|right)\]/)){
    doThis; // direction spotted
    }
    else{
    doThat; // no direction spotted
    };

    But… there is maybe another solution that leads more straigthforwardly to the same thing.

    //===================

    Edit: actually if you remove the (?!$) in the regexp (which tells not to match if the [up/down] pattern if right at the end of the string, i added this so you dont end up with an empty entry) then the last entry of string NEVER has a direction and all other have one:

    strings = textIn.replace(/([(up|down|right|left)])s*/g, “$1″+D).split(D);
    N = strings.length;

    //>>> now all entries strings[n] (n=0,… N-2) have a direction, the last one not (and can be an empty string). Maybe better that way.

  • Hi,

    here is a possibitity, not sure it is the most efficient one though.
    It adds a delimiter tag after each of these patterns, then splits the string:

    var textIn = “go [up] or [down] then [right] but not [left]”;
    var D = “#”; // or something else
    var strings = textIn.replace(/(\[(up|down|right|left)\])\s*(?!$)/g, “$1″+D).split(D); // an array of substrings of textIn

    Xavier

  • Xavier Gomez

    July 29, 2014 at 9:21 am in reply to: Order layers by Y position

    A script doing this already exists: see Sortie on aescripts.com

    Xavier.

  • Xavier Gomez

    July 19, 2014 at 9:00 am in reply to: Repeating text on every line

    You forgot to add the characters themselves in the loop.

    s = myText = “subject”;
    for(i=1; i<8; i++) s += "\r" + myText;
    s;

    Xavier

  • Xavier Gomez

    July 17, 2014 at 6:14 pm in reply to: tirigger emitter with marker

    Hi again,

    it’s not completely clear to me what number you are refering to.

    If it is how many particles are emitted at each marker, do it by changing the emit rate value (which the expression reads for its final output).
    If it is to emit not at all markers but say every 3 markers, something like this, or the other way round, 3 times between 2 consecutive markers, then the expression should be modified slightly.

    Xavier.

  • Xavier Gomez

    July 17, 2014 at 5:34 pm in reply to: tirigger emitter with marker

    You can try this (expression to put in the emitter’s emit rate property, change “Null 1” to the name of the layer carrying the markers):

    // the emitter emits at the control layer's markers
    // the emit rate at markers is controlled by the emitter key value
    // how fast it decays after each marker is controlled by this param:
    decay = 25;

    // get last key index;
    m = thisComp.layer("Null 1").marker;
    idx = m.numKeys ? m.nearestKey(time).index : 0;
    if (idx && m.key(idx).time>time) idx--;
    //
    (idx<1) ? 0 : value*Math.exp(-decay*(time-m.key(idx).time));

    Xavier

  • Xavier Gomez

    July 16, 2014 at 11:01 am in reply to: How do I add Layer Styles to a Layer with script?

    Coincidence, David Torno very recently made a much more exhaustive list. See this thread: https://forums.adobe.com/message/6541252#6541252

    Edit: concerning layer styles, it is a pity they don’t work like Text Animator Properties, or shape stroke dashes: properties are always there, adding a property reveals it, removing a property hides it, etc: A lot simpler.

    Xavier

  • Xavier Gomez

    July 12, 2014 at 7:42 am in reply to: Count from 0 to 1 Million dollars

    First, add a slider control to your text layer (in the effect panel) and rename it “Count” (to match the name i used in the expression);

    Next, alt+click the stopwatch of the source text property of the text. A text field appears for the expression: paste the expression there.

    You have to animate the slider or the text will stick to $0.

    Xavier

  • Xavier Gomez

    July 12, 2014 at 7:32 am in reply to: Count from 0 to 1 Million dollars

    “$” + effect(“Count”)(“Slider”).value.toFixed(0).replace(/\d{1,3}(?=(\d{3})+(?!\d))/g , “$&,”);

    That’s without tabbing (as in your post).
    Edit: for more decimals, replace toFixed(0) by toFixed(2) (for instance).

    Xavier.

  • Xavier Gomez

    July 10, 2014 at 6:15 am in reply to: finding a vector between to point in space

    I don’t know what plane you are talking about…

    If your plane is a layer, then a normal to the “plane” can be the vector [0,0,1] (in layer coordinate system). To get the coordinates of that vector in world coordinate system, use toWorld, then normalize to get a unit vector in world system (in case your layer is scaled etc):

    normalize(thisComp.layer(“Plane”).toWorld([0,0,1]));

    Something like this. I barely do any 3D so i’m not sure to be honnest… That’s a whole different question from the first one 😉

    If your plane is not a layer, then you should give more info about that plane…

    Xavier.

Page 19 of 32

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