Skip to main content
Participating Frequently
December 17, 2023
Question

need a help on trim path animation

  • December 17, 2023
  • 2 replies
  • 690 views

I have multiple paths in single layer, if i use trim path for this layer... then am getting  one path after another continouly, but i need some little break (like 5 to 10 frames) in between each path... Please provide the expression that I could use for a pause of few seconds between each path.

This topic has been closed for replies.

2 replies

Legend
December 17, 2023

I wrote this code; you can edit the initial variables. (pathDuration and timeBreak)

I hope you have the same hierarchy as I do.

 

 

function framesToTime(frames) {
  return thisComp.frameDuration * frames;
}

var proj = app.project;
var thisComp = proj.activeItem;

// in seconds or use framesToTime(15) for 15 frames
var pathDuration = 5;
var timeBreak = .5;


if (!thisComp.selectedLayers.length) {
  alert('Select a shape layer');
}

app.beginUndoGroup("Undo");
var selectedLayer = thisComp.selectedLayers[0];
var currentTime = 0;

for (var i = 1; i <= selectedLayer.content.numProperties; i++) {
  var shapeGroup = selectedLayer.content.property(i).property("ADBE Vectors Group");
  var trimPath = shapeGroup.addProperty("ADBE Vector Filter - Trim");
  trimPath.property("ADBE Vector Trim End").setValueAtTime(currentTime, 0);
  trimPath.property("ADBE Vector Trim End").setValueAtTime(currentTime + pathDuration, 100);
  currentTime += pathDuration + timeBreak;
}

app.endUndoGroup();

 

 

Participating Frequently
December 18, 2023

Thank you, really appreciate your time and work. 

 

Since each shape has different length, can the pathDuration variable be set dynamically in correspond to the length of the shape? I will send you my work in DM for clear understanding.

Legend
December 17, 2023

The simplest approach is to create one Trim Path for each shape.

Using expressions, it should be possible if your paths don't contain bezier curves.

 

Participating Frequently
December 17, 2023

Hi thanks for replying, but I have more than 50 layers this method takes much time that's why I'm looking for some expressions or short cut

Legend
December 17, 2023

Then, you'll need to use a script to add a trim path property and keyframes to each shape.

But how do you determine the animation duration for each path, is it fixed??