Forum Replies Created

Page 93 of 1081
  • Dan Ebberts

    April 18, 2022 at 1:08 pm in reply to: Increase position with comp markers

    Like this maybe:

    easeTime = 1;

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

    m = marker;

    y = 0;

    if (m.numKeys > 0){

    n = m.nearestKey(time).index;

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

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

    y += sy.valueAtTime(m.key(i).time);

    }

    if (n > 0){

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

    y += ease(t,0,easeTime,0,sy.valueAtTime(m.key(n).time));

    }

    }

    value + [0,y]

  • Did you try thisProperty.name ?

  • Dan Ebberts

    April 14, 2022 at 10:49 pm in reply to: Scripting for Bounding box around text or AI file

    I’m not what all you’re looking for, but whatever you want to do is probably do-able. This just expands on what you have a little to maybe give you some ideas. I think I’d position the rectangle with an expression, so I’ve included how to do that. Anyway, I hope it’s helpful.

    function addShapeOnTop(){

    var comp = app.project.activeItem;

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

    alert("No comp active.");

    return;

    }

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

    alert("No layer selected.");

    return;

    }

    var margin = 10;

    var textLayer = comp.selectedLayers[0];

    var shapeLayer = comp.layers.addShape();

    shapeLayer.name = "Shape on top";

    var shapeLayerContents = shapeLayer.property("ADBE Root Vectors Group");

    var rectangleGroup = shapeLayerContents.addProperty("ADBE Vector Group");

    rectangleGroup.name = "Rectangle 1";

    var rectangleContents = rectangleGroup.property("ADBE Vectors Group");

    var pathGroup = rectangleContents.addProperty("ADBE Vector Shape - Rect");

    var sourceRect = textLayer.sourceRectAtTime(0,false);

    pathGroup.property("ADBE Vector Rect Size").setValue([sourceRect.width + margin*2,sourceRect.height + margin*2]);

    var pathStroke = rectangleContents.addProperty("ADBE Vector Graphic - Stroke");

    var pathFill = rectangleContents.addProperty("ADBE Vector Graphic - Fill");

    var expr = 'L = thisComp.layer("' + textLayer.name + '");\r' +

    'r = L.sourceRectAtTime(time,false);\r' +

    'L.toComp([r.left+r.width/2,r.top+r.height/2])';

    shapeLayer.property("Position").expression = expr;

    shapeLayer.moveAfter(textLayer);

    }

    addShapeOnTop();

  • Dan Ebberts

    April 14, 2022 at 7:39 pm in reply to: help with text indenting on 2nd line

    It looks like it might have something to do with kerning. If you highlight the first line, the kerning selection in the Paragraph panel is blank. If you highlight the second line, you get a dimmed out “Metrics”. If you just select the layer (no highlighted text) and select Metrics or Optics, all lines get the same indent. This is not my area of expertise, just an observation–I hope it is of some use to you…

  • Dan Ebberts

    April 13, 2022 at 7:45 pm in reply to: Anchor point positioning

    Oops, those are messed up. The first one should be:

    var r = myLayer[i].sourceRectAtTime(0,true);

    var ap = myLayer[i].property("Anchor Point").value;

    var delta = [r.left - ap[0] , r.top + r.height/2 - ap[1]];

    var pos = myLayer[i].property("Position").value;

    myLayer[i].property("Anchor Point").setValue([ap[0] + delta[0], ap[1] + delta[1]]);

    myLayer[i].property("Position").setValue([pos[0] + delta[0], pos[1] + delta[1]]);

    and the second one should be:

    var r = myLayer[i].sourceRectAtTime(0,true);

    var ap = myLayer[i].property("Anchor Point").value;

    var delta = [r.left + r.width/2 - ap[0] , r.top - ap[1]];

    var pos = myLayer[i].property("Position").value;

    myLayer[i].property("Anchor Point").setValue([ap[0] + delta[0], ap[1] + delta[1]]);

    myLayer[i].property("Position").setValue([pos[0] + delta[0], pos[1] + delta[1]]);

  • Dan Ebberts

    April 13, 2022 at 7:27 pm in reply to: Anchor point positioning

    Yes:

    var delta = [r.left + r.width/2, r.top];
  • Dan Ebberts

    April 13, 2022 at 4:23 pm in reply to: Anchor point positioning

    Something like this inside your loop, I think:

    var r = myLayer[i].sourceRectAtTime(0,true);

    var delta = [r.left, r.top + r.height/2];

    var ap = myLayer[i].property("Anchor Point").value;

    var pos = myLayer[i].property("Position").value;

    myLayer[i].property("Anchor Point").setValue([ap[0] + delta[0], ap[1] + delta[1]]);

    myLayer[i].property("Position").setValue([pos[0] + delta[0], pos[1] + delta[1]]);

  • If your comp has a single shape in it, and it’s layer 1 in that comp, something like this might work on the following layer if the comp layer does or doesn’t have collapse transformations on:

    L = thisComp.layer(index-1).source.layer(1);

    r1 = L.sourceRectAtTime(time,false);

    LL = L.toComp([r1.left,r1.top+r1.height]);

    LR = L.toComp([r1.left+r1.width,r1.top+r1.height]);

    L2 = thisComp.layer(index-1);

    LL = L2.toComp(LL);

    LR = L2.toComp(LR);

    r2 = sourceRectAtTime(time,false);

    UL = toComp([r2.left,r2.top]);

    UR = toComp([r2.left+r2.width,r2.top]);

    deltaX = (LL[0] + LR[0])/2 - (UL[0] + UR[0])/2;

    deltaY = LR[1] - UR[1];

    value + [deltaX,deltaY]

  • Try this position expression:

    L = thisComp.layer(index-1);

    r1 = L.sourceRectAtTime(time,false);

    LL = L.toComp([r1.left,r1.top+r1.height]);

    LR = L.toComp([r1.left+r1.width,r1.top+r1.height]);

    r2 = sourceRectAtTime(time,false);

    UL = toComp([r2.left,r2.top]);

    UR = toComp([r2.left+r2.width,r2.top]);

    deltaX = (LL[0] + LR[0])/2 - (UL[0] + UR[0])/2;

    deltaY = LR[1] - UR[1];

    value + [deltaX,deltaY]

  • If I understand what you’re after, it’s a little more complex. This doesn’t account for all possibilities, but it should get you pretty close (update myNum for each group):

    myNum = 1;

    easeTime = 1;

    s = thisComp.layer("Null").effect("Slider Control")("Slider");

    if (s.numKeys > 1){

    n = s.nearestKey(time).index;

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

    if (n > 0){

    if (s.key(n).value == myNum){

    ease(time,s.key(n).time,s.key(n).time+easeTime,0,100);

    }else{

    if (n > 1){

    if (s.key(n-1).value == myNum){

    ease(time,s.key(n).time,s.key(n).time+easeTime,100,0);

    }else{

    0;

    }

    }else{

    0;

    }

    }

    }else{

    0;

    }

    }else

    s.value == myNum ? 100 : 0

Page 93 of 1081

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