4 Replies Latest reply on Sep 23, 2012 11:08 AM by Muppet Mark

    Finding a Point on a Path

    Squisterson Level 1

      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?



        • 1. Re: Finding a Point on a Path
          [Jongware] Most Valuable Participant

          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.

          1 person found this helpful
          • 2. Re: Finding a Point on a Path
            moluapple Level 4

            With Scriptographer it is really easy:


            1 person found this helpful
            • 3. Re: Finding a Point on a Path
              Squisterson Level 1

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

              • 4. Re: Finding a Point on a Path
                Muppet Mark Level 5

                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…

                1 person found this helpful