Forum Replies Created

Page 84 of 1081
  • Dan Ebberts

    June 30, 2022 at 2:53 pm in reply to: Importing file by using the script file’s path

    Your code works fine for me.

  • Yes, please report back if you find anything. I tried valueAtTime() with keyTime() and it didn’t help, but maybe you’ll figure something out.

  • I get the same result. This looks like a bug to me. I’m not sure how you can work around it. (I’ve reported it to Adobe).

  • <div>The script version would be like this:</div>

    var myLayer = app.project.activeItem.layer(1);

    var r = myLayer.sourceRectAtTime(0,false);

    var myMask = myLayer.property("Masks").addProperty("Mask");

    var myPath = myMask.property("Mask Path");

    var myShape = myPath.value;

    myShape.vertices = [[r.left,r.top],[r.left+r.width,r.top+r.height/5],[r.left,r.top+2*r.height/5],[r.left+r.width,r.top + 3*r.height/5],[r.left,r.top+4*r.height/5],[r.left+r.width,r.top+r.height]];

    myShape.inTangents = [];

    myShape.outTangents = [];

    myShape.closed = false;

    myPath.setValue(myShape);

    Basically you’re just using the layer’s left, top, width, and height extents as provided by sourceRectAtTime() to calculate where you want the mask vertices to be. I just took a shot at it based on your diagram. Since the mask is all corner points, you can provide empty arrays for the in and out tangents.

  • Dan Ebberts

    June 28, 2022 at 10:26 pm in reply to: Loop out at marker

    Do you mean “pingpong”? That would be like this I guess:

    startMarkerTime = marker.key(1).time;

    if (time <= startMarkerTime) {

    0;

    } else {

    t = time - startMarkerTime;

    t1 = key(1).time;

    t2 = key(2).time;

    d = t2 - t1;

    n = Math.floor(t/d);

    n % 2 ? t2 - t%d : t1 + t%d;

    }

  • Are you talking about scripting or expressions? With expressions you would just click on your vector layer with the pen tool to create a mask point and add an expression something like this to the Mask Path:

    r= sourceRectAtTime(time,false);

    p = [[r.left,r.top],[r.left+r.width,r.top+r.height/5],[r.left,r.top+2*r.height/5],[r.left+r.width,r.top + 3*r.height/5],[r.left,r.top+4*r.height/5],[r.left+r.width,r.top+r.height]];

    createPath(p,[],[],false)

    It would be similar but a little more involved with scripting.

  • Dan Ebberts

    June 28, 2022 at 8:59 pm in reply to: Loop out at marker

    Probably close to this:

    startMarkerTime = marker.key(1).time;

    if (time <= startMarkerTime) {

    0;

    } else {

    (time - startMarkerTime)%(key(numKeys).time - key(1).time);

    }

  • Dan Ebberts

    June 25, 2022 at 6:44 pm in reply to: Start, shuffle, return to position

    I suspect you might have better luck if you were to post a keyframed mockup project of what this might look like. “shuffle around” is pretty vague…

  • Dan Ebberts

    June 25, 2022 at 2:56 am in reply to: script to swap the positions of n layers?

    This is a simple example that will take the selected layers and randomly swap their positions. Might give you some ideas, or a place to start:

    var myLayers = app.project.activeItem.selectedLayers;

    var myPositions = [];

    for (var i = 0; i < myLayers.length; i++){

    myPositions.push(myLayers[i].property("Position").value);

    }

    var temp;

    var idx;

    for (var i = 0; i < myPositions.length; i++){

    idx = i + Math.floor(generateRandomNumber()*(myPositions.length-i));

    temp = myPositions[i];

    myPositions[i] = myPositions[idx];

    myPositions[idx] = temp;

    }

    for (var i = 0; i < myLayers.length; i++){

    myLayers[i].property("Position").setValue(myPositions[i]);

    }

  • Try this:

    thisLayer.content.numProperties
Page 84 of 1081

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