Skip to main content
Known Participant
September 23, 2012
Question

Finding a Point on a Path

  • September 23, 2012
  • 2 replies
  • 1153 views

Is there any way to find a specific point on a path, that is not necessarily an anchor point?

What I'd like to be able to do is tell Illustrator "Give me the coordinates of the point that's exactly at half of this path's length" or "... exactly 25% ...". And if that's possible, can I somehow add an anchor point to that point, or cut the path at that point?

Thanks!

This topic has been closed for replies.

2 replies

Inspiring
September 23, 2012

With Scriptographer it is really easy:

http://scriptographer.org/reference/ai/path/#

Known Participant
September 23, 2012

Thanks! Yeah, I'm trying to avoid Scriptographer, since there's no version for CS6 in sight.

Inspiring
September 23, 2012

What I think you will need to do is… avoid the pathPoints.add() method this adds a point to the end of the current path then allows you to move it's position… Store all path points to an array, insert your new pathPoint item into that array then use the pathItem.setEntirePath() method… Me and Monsieur Bézier are going to have to have words one day…

Jongware
Community Expert
Community Expert
September 23, 2012

For straight lines only, or optionally for curved lines as well? For a given straight path segment, or any object?

Straight lines is straightforward interpolation:

for every pair of points (A,B) test if your target is between Ax and Bx, and Ay and By. If so, your coordinates are Ax+d*(Bx-Ax) and Ay+d*(By-Ay) (where d is your factor in decimals, 25% is 0.25).

Curved lines are represented by Bézier curves, and there is no straightforward solution. In that case you have to subdivide the curve until you are "close enough". Still fairly easy, but I cannot type *that* from memory. :-)

Note that there is a difference in the order of points: 25% up the path from A to B is different then from B to A.