Skip to main content
GeoffreyBeatty
Participant
May 5, 2023
Answered

Is there an equivalent to pointOnPaths for scripting?

  • May 5, 2023
  • 2 replies
  • 382 views

I'm working on a script that collects the path data from the selected layer and then checks to measure the pixel length of each path. I was using pointOnPath within an expression (h/t to Dan Ebberts) as a test, but I'm trying to create a more general tool through scripting, and pointOnPath doesn't seem to be accessible from scripts. Am I missing something? Is there an alternative way to get the path length in a script?

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

With scripting, you just have access to the vertices, inTangents, and outTangents. In theory, you could come up with your own iterative routine to calculate the length of each bezier segment, but it would probably be easier to use a temporary pointOnPath() expression to cut the path into a bunch of small segments and approximate the length that way.

2 replies

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
May 6, 2023

With scripting, you just have access to the vertices, inTangents, and outTangents. In theory, you could come up with your own iterative routine to calculate the length of each bezier segment, but it would probably be easier to use a temporary pointOnPath() expression to cut the path into a bunch of small segments and approximate the length that way.

Mylenium
Legend
May 6, 2023

You can apply temporary expressions in scripts, bake the keyframes and use those values. You'll of course have to include extra loops to clean up after yourself and delete all the temp stuff. Otherwise you can always implement the Bèzier algorithm yourself and do al lthe calculations. It's really not that difficult.

 

Mylenium