Skip to main content
Participant
June 25, 2024
Answered

Trim path follow expression

  • June 25, 2024
  • 1 reply
  • 456 views

Greetings,

I have an expression for a shape to follow the trim path of another shape.

 

var path = thisComp.layer("Shape Layer 3").content("Path 1").path;

var trimPath = thisComp.layer("Shape Layer 3").content("Trim Paths 1").end / 100;

var targetLayer = thisComp.layer("Shape Layer 3");

var point = path.pointOnPath(trimPath);

targetLayer.toComp(point)

 

Would it be possible to account for trim path offset (on the trim paths 1)? 

 

This topic has been closed for replies.
Correct answer Dan Ebberts

It's probably going to be something like this, although I'm not sure what should happen when the offset wraps around:

 

 

var targetLayer = thisComp.layer("Shape Layer 3");
var path = targetLayer.content("Path 1").path;
var trimPath = targetLayer.content("Trim Paths 1").end / 100;
var offset = (targetLayer.content("Trim Paths 1").offset%360)/360;
var point = path.pointOnPath((trimPath + offset)%1);

targetLayer.toComp(point)

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
June 25, 2024

It's probably going to be something like this, although I'm not sure what should happen when the offset wraps around:

 

 

var targetLayer = thisComp.layer("Shape Layer 3");
var path = targetLayer.content("Path 1").path;
var trimPath = targetLayer.content("Trim Paths 1").end / 100;
var offset = (targetLayer.content("Trim Paths 1").offset%360)/360;
var point = path.pointOnPath((trimPath + offset)%1);

targetLayer.toComp(point)