Forum Replies Created

Page 96 of 1081
  • Dan Ebberts

    March 8, 2022 at 6:55 pm in reply to: help with my syntax on a source text expression

    Sorry, you can’t use an expression to set multiple fonts in a single text layer.

  • Just put this line:

    if (myTextDoc.text == "") continue;

    right before this one:

    markerVal.comment = myTextDoc.text;

  • This should get you close:

    function keyframesToMarkers(){

    var myComp = app.project.activeItem;

    if (myComp == null || ! (myComp instanceof CompItem)){

    alert ("No comp active.");

    return;

    }

    if (myComp.selectedLayers.length == 0){

    alert ("No layer selected.");

    return;

    }

    var myLayer = myComp.selectedLayers[0];

    if ( ! (myLayer instanceof TextLayer)){

    alert ("Selected layer is not a text layer.");

    return;

    }

    var markerVal = new MarkerValue("");

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

    var myTextDoc;

    for (var i = 1; i <= mySourceText.numKeys; i ++){

    myTextDoc = mySourceText.keyValue(i);

    markerVal.comment = myTextDoc.text;

    myLayer.property("Marker").setValueAtTime(mySourceText.keyTime(i),markerVal);

    }

    }

    keyframesToMarkers();

  • Dan Ebberts

    March 4, 2022 at 3:48 am in reply to: X rotation affects toWorld/toComp properties

    What’s the expression for the anchor point?

  • Something like this maybe:

    m = marker;

    val = value;

    if (m.numKeys > 0){

    n= m.nearestKey(time).index;

    if (time < m.key(n).time) n--;

    if (n > 0){

    t = time - m.key(n).time;

    val = (t > m.key(n).duration) ? 0 : 100;

    }else{

    val = 0;

    }

    }

    val

  • I think you actually have two separate problems. One is that if you have an expression in a sub comp referencing an animated control in a outer comp and the sub comp layer in the outer comp doesn’t start at time = 0, your expression needs to compensate for that offset start time. So your example would look like this:

    C = comp("Parent");

    ctrl = C.layer("CONTROL").effect("Slider Control")("Slider");

    L = C.layer(thisComp.name);

    ctrl.valueAtTime(time + L.startTime) < 2 ? 100 : 0

    However, if you are duplicating the sub comp layer in the outer comp, that technique will only work for the top-most layer. To get it to work for any duplicates, you’d have to duplicate the sub comp in the project bin and make sure it has its own comp name. It has to do with how precomps work–if you just duplicate a precomp layer, the duplicate layer still references the same precomp and it only renders once, so it can’t render differently in different layer instances.

  • This is a little function that should set hideShyLayers to true in every comp:

    function shyAllComps(){

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

    if (app.project.item(i) instanceof CompItem){

    app.project.item(i).hideShyLayers = true;

    }

    }

    }

  • Dan Ebberts

    March 1, 2022 at 6:56 am in reply to: Copy-paste goes wrong

    clamp(Math.floor(gaussRandom(0,2)),0,1) should work.

  • Dan Ebberts

    February 26, 2022 at 10:18 pm in reply to: Copy-paste goes wrong

    Math.floor(gaussRandom(0,2)) is going to give you the occasional -1, and if that happens when idx is 0, you’ll get an illegal array index.

  • Dan Ebberts

    February 24, 2022 at 10:07 pm in reply to: Random value each keyframe

    This should give you a different color at each keyframe. It does work differently because it has to go through all previous keyframes to calculate the current color:

    colors = [[1,0,0,1], //red

    [0,1,0,1], // green

    [0,0,1,1], // blue

    [1,1,0,1], // yellow

    [0,1,1,1], // cyan

    [1,0,1,1]]; // magenta

    p = effect("Slider Control")("Slider");

    seedRandom(index,true);

    idx = Math.floor(random(colors.length));;

    if (p.numKeys > 0){

    n = p.nearestKey(time).index;

    if (time < p.key(n).time) n--;

    for (i = 1; i <= n; i++){

    idx = (idx + Math.floor(random(1,colors.length)))%colors.length;

    }

    }

    colors[idx]

Page 96 of 1081

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