Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions add Expression with a Script

  • add Expression with a Script

    Posted by Matthias Weiner on March 12, 2018 at 12:41 pm

    Hello,
    I’ll hope this is the right forum for my question. I have written an expression and wanted to ad this by a script to my selected layer. The problem is that I can’t add this expression in between the “” with all its special chars, commands and comments. I only can convert the expression to a binary and add this in between the “”. I will share my code in the hope of getting help ☺ The script adds the expression to every puppet-pin position to the selected layers. The expression finds special named NULL’s in a limited distance and take the closest and get its position. I developed this to manage fast usage of facetracking-points as NULL’s to transform a layer with nearly same positioned puppet-pins. Here is an example Video: https://www.facebook.com/picmention/videos/1400056170026071/

    Thank you!

    //Script by Picmention - 2018
    //Puppet Master V1.3
    //Fügt auf alle Puppet-Pins der selektierten Ebenen das Puppet-Master Script ein. Selbiges ist jedoch binär!

    InsertExpression(this);

    function InsertExpression(thisObj)
    {
    var activeItem = app.project.activeItem; //Schreibt in die Variable die selektierten Items
    var PuppetMasterExp = "eval('@JSXBIN@ES@2.0@MyBbyBn0ABgDbyBn0AUJGnABjzHjIjJjUjOjBjNjFBfneEiOiViMiMfJHnABjzGjMifjPjWjFjSCfneLiOiViMiMifiDjFjOjUjFjSfJInABjzKjMifjPjWjFjSjSjJjEjFDfncffJLnABjzJjNjBjYiSjBjEjJjVjTEfndiAfJOnABjzKjUjIjFiDjIjPjPjTjFjOFfndyBfJPnABjzGjUiDiEjJjTjUGfjEfnfJSnABjzHjDifjMjFjOjHjIHfXzGjMjFjOjHjUjIIfjBfnfgyVbyBn0ACJVnAjzHjDjPjOjUjFjOjUJfJyVnABjzHjIjBjTiDjPjOjUKfnctfABnzBjFLnbyBn0ABJyVnABjKfncffgYbyBn0AFJYnABjzCjMjOMfXzEjOjBjNjFNfjzGjTjPjVjSjDjFOfnfJZnABjzCjMjMPfXIfjMfnfOgaJganABjKfnctfACzChdhdQEXzGjTjVjCjTjUjSRfjMfRCCzBhNSjPfnndCFdCffnneCjBjJnOgbJgbnABjKfnctfACQEXRfjMfRCCSjPfnndDFdDffnneDjQjEjGnOgcJgcnABjKfnctfACQEXRfjMfRCCSjPfnndDFdDffnneDjFjQjTnABnLnnOgfJgfnABjzCjQhRTfjzFjWjBjMjVjFUfnfACQjKfnnctJhAnABjTfEjzGjUjPiDjPjNjQVfRCjUfjzHjJjOiQjPjJjOjUWfffnfahCbhEn0ADJhEnABjzBjMXfEXzFjMjBjZjFjSYfjzIjUjIjJjTiDjPjNjQZfRBjzBjJgafffnfJhFnABjzBjTgbfEXRfXNfjXfRCFdAjHfffnfOhIbhKn0ADJhKnABjzCjQhSgcfEXVfjXfRCXzLjBjOjDjIjPjSiQjPjJjOjUgdfjXfXWfjXfffnfJhLnABjzEjEjJjTjUgefEjIfRCjTfjgcfffnfOhMbhOn0ACJhOnABjGfjgefnfJhPnABjFfjgafnfAUzChGhGgfCzChchdhAjgefjEfnnChAjgefjGfnnnnnACQjgbfjBfnnnAjgafBXzJjOjVjNiMjBjZjFjSjThBfjZfByBhAOhUJhUnABjFfXzFjJjOjEjFjYhCfEXYfjZfRBjCfffnfACQjDfnnctnJhXnABjXfEXYfjZfRBjFfffnfJhYnABjTfEXVfjXfRCXgdfjXfXWfjXfffnfJhZnABjgcfEXVfjXfRCXgdfjXfjzEjUjJjNjFhDfffnfJhcnABjzDjQhRjChEfEjzRjGjSjPjNiDjPjNjQiUjPiTjVjSjGjBjDjFhFfRCjTfjWfffnfJhdnABjzDjQhSjChGfEjhFfRCjgcfjhDfffnfJhenABjzDjEjJjGhHfCSjhGfjhEfnnnfJhfnABjzEjUjFjNjQhIfCzBhLhJjUfjhHfnnnfJiCnAjhIfABnLnbyBn0ABJiInAjUf0DzAhKByB');"; //Fügt die Expression in die Variable ein
    if (activeItem.selectedLayers.length >= 1) //Prüfen ob mehr als ein Layer markiert ist
    {
    for (var k = 0; k < activeItem.selectedLayers.length; k++)
    {
    if(app.project.activeItem.selectedLayers[k].matchName == "ADBE AV Layer" && app.project.activeItem.selectedLayers[k].effect("Marionette").arap != null) //Prüfe ob überhaupt Layer und keine Kamera ist und wirklich ein Marionetten-Effekt
    {
    var i = 0;
    while(i >= 0)
    {
    i++;
    var MPin = "Marionetten-Pin "+i;
    if(app.project.activeItem.selectedLayers[k].effect("Marionette").arap.mesh("Gitter 1").deform(MPin) != null)
    {
    app.project.activeItem.selectedLayers[k].effect("Marionette").arap.mesh("Gitter 1").deform(MPin).position.expression = PuppetMasterExp;
    }
    else
    {
    break; //Aus der Schlefe hüpfen
    }
    }
    }
    }
    }
    else
    {
    alert("Bitte mindestens einen Layer auswählen");
    return;
    }
    }

    here is the expression I want to add in my script:

    //Script by Picmention
    //Puppet-Master V1.3
    //19.01.2018

    try
    {
    //Hitname
    hitname = "NULL";
    l_over = "NULL_Hand_Links";
    l_override = false; //if true use l_over instead of hitname-search
    force_vec = true; //true, false, auto)

    //Max Radius
    maxRadius = 64;

    //TheChoosen
    theChoosen = -1;
    tCDist = maxRadius;

    //Länge des Hitnames
    c_lengh = hitname.length;

    //Test if this is a vector mask
    try{content;hasCont = true;}catch(e){hasCont = false};

    //Check if source is vector based layer. If so we implizit that vector optimization is enabled
    try{ln = source.name;
    ll = ln.length;
    if(ln.substr(ll-2,2) == "ai") hasCont = true;
    if(ln.substr(ll-3,3) == "pdf") hasCont = true;
    if(ln.substr(ll-3,3) == "eps") hasCont = true;
    }catch(e){};

    if(force_vec == true) hasCont = true;
    if(force_vec == false) hasCont = false;

    if(hasCont == true) p1 = value;
    else p1 = toComp(value, inPoint);

    for (i=1; i &lt;= thisComp.numLayers; i++)
    {
    l = thisComp.layer(i);
    s = l.name.substr(0,c_lengh);

    //Test auf Hitname
    if(s == hitname)
    {
    p2 = l.toComp(l.anchorPoint, l.inPoint);
    dist = length(p1,p2);
    if(dist &lt;= maxRadius && dist &lt;= tCDist)
    {
    tCDist = dist;
    theChoosen = i;
    }
    }
    }

    if(l_override == true) theChoosen = thisComp.layer(l_over).index;

    //Var
    l = thisComp.layer(theChoosen); //The NULL object where the movement depends on
    p1 = l.toComp(l.anchorPoint, l.inPoint); //The position at inPoint time on the comp
    p2 = l.toComp(l.anchorPoint, time); //The position at current time on the comp

    //Calc
    if(hasCont == true) dif = p2-p1; //Use this calculation if it is a vectorized layer
    else
    {
    p1b = fromCompToSurface(p1, inPoint); //Calculate the position on this layer at inPoint time
    p2b = fromCompToSurface(p2, time); //Calculate the position on this layer at current time
    dif = p2b-p1b; //Calculate the difference
    }
    temp = value+dif; //Add the initial value to the difference

    //Out
    temp; //print out
    }
    catch(e)
    {
    //Die Antwort auf alles
    value;
    }

    Matthias Weiner replied 8 years, 5 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

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