8 Replies Latest reply: Sep 30, 2010 5:15 AM by [Jongware] RSS

    Illustrator CS3: how to calculate exact distance between two point?

    Red83 Community Member

      This is my line.

       

      Immagine 1.jpeg

       

      I have to measure its exact length. How can I do?
      If I use the measure tool, the cursor does not select the snap points, so I can have only an approximate measure.
      Is there a quick way to calculate the exact distance between two points?

        • 1. Re: Illustrator CS3: how to calculate exact distance between two point?
          Jacob Bugge CommunityMVP

          Red,

           

          Presuming you have (as shown, or create) a straight path between the points, you may use the Pathlength/PathArea Filter plugin from Telegraphics, http://www.telegraphics.com.au/sw/, or use the secret programmer's debugging palette (Ctrl+Alt+Shift+F12/Cmd+Option+Shift+F12 to open it) and find the value.

           

          Maybe the Measure Tool reacts to points with Smart Guides on in later versions (I am still with 10).

           

          And then there is the laborious way, using the (Direct) Selection Tool and calculating from the values of W and H.

          • 2. Re: Illustrator CS3: how to calculate exact distance between two point?
            [Jongware] CommunityMVP

            Part of my Three Touching Circles script needs the length of each of a triangle's lines; removing everything obsolete leaves this:

             

            //DESCRIPTION:How Long Is That Line
            // A Jongware Script, 30-Sep-2010
             
            if (app.documents.length > 0 && app.selection.length == 1 && app.selection[0].hasOwnProperty("pathPoints") && app.selection[0].pathPoints.length == 2)
            {
             p1 = new point (app.selection[0].pathPoints[0].anchor);
             p2 = new point (app.selection[0].pathPoints[1].anchor);
             dc = p1.distance(p2);
             alert ("This line is "+dc+" pts long");
            }
             
            function point (arr)
            {
                 this.x = arr[0];
                 this.y = arr[1];
                 this.distance = function (pt) { return Math.sqrt ( (this.x-pt.x)*(this.x-pt.x) + (this.y-pt.y)*(this.y-pt.y) ) };
            }
             
            
            • 3. Re: Illustrator CS3: how to calculate exact distance between two point?
              JETalmage Community Member

              Document Info Palette flyout menu: Turn on SelectionOnly and Objects. The palette will show you the length.

               

              JET

              • 4. Re: Illustrator CS3: how to calculate exact distance between two point?
                Jacob Bugge CommunityMVP

                In CS3?

                 

                I will try to remember.

                • 5. Re: Illustrator CS3: how to calculate exact distance between two point?
                  JETalmage Community Member

                  If the two points of interest are not adjacent, use the Line Tool, not the useless Measure tool. Draw a line, snapping to the two points of interest. Look at the Document Info palette for the measure. Delete the line.

                   

                  JET

                  • 6. Re: Illustrator CS3: how to calculate exact distance between two point?
                    Red83 Community Member

                    Jet

                     

                    I think your answer is the more correct one, even if the method is a little too cumbersome.

                    But the blame lies with Illustrator, not your

                     

                    Thank you very much

                    • 7. Re: Illustrator CS3: how to calculate exact distance between two point?
                      [Jongware] CommunityMVP

                      I don't find that option in CS4 either ... (I do get a total width and height, though -- and a distance when dragging.)

                       

                      Just in case it doesn't exist after all: added some spit-and-polish to the Measure script. You can select a line and get its length, or any two anchor points (from any two objects!) and get the distance between these.

                       

                       

                      //DESCRIPTION:How Long Is That Line
                      // A Jongware Script, 30-Sep-2010
                      if (app.documents.length > 0)
                      {
                       selpts = new Array();
                       if (app.selection.length == 1 && app.selection[0].hasOwnProperty("pathPoints") && app.selection[0].pathPoints.length == 2)
                       {
                        Name = "Length";
                        selpts.push (new point (app.selection[0].pathPoints[0].anchor));
                        selpts.push (new point (app.selection[0].pathPoints[1].anchor));
                       } else
                       {
                        Name = "Distance";
                        for (s=0; s<app.selection.length; s++)
                        {
                         if (app.selection[s].hasOwnProperty("pathPoints"))
                         {
                          for (pt=0; pt<app.selection[s].pathPoints.length; pt++)
                          {
                           if (app.selection[s].pathPoints[pt].selected == PathPointSelection.ANCHORPOINT)
                            selpts.push (new point (app.selection[s].pathPoints[pt].anchor));
                          }
                         }
                        }
                       }
                       if (selpts.length == 2)
                       {
                        dc = selpts[0].distance(selpts[1]);
                        alert (Name+": "+round(dc,3)+" pt\r = "+round(dc/72,4)+" in\r = "+round(dc*25.4/72,3)+" mm");
                       } else
                       {
                        alert ("Invalid selection -- please select one single line, or any two anchor points");
                       }
                      }
                       
                      function point (arr)
                      {
                           this.x = arr[0];
                           this.y = arr[1];
                           this.distance = function (pt) { return Math.sqrt ( (this.x-pt.x)*(this.x-pt.x) + (this.y-pt.y)*(this.y-pt.y) ) };
                      }
                      function round(value,to)
                      {
                       var dec = 1;
                       while (to-- > 0)
                        dec *= 10;
                       return Math.round(value*dec)/dec;
                      }
                      
                      • 8. Re: Illustrator CS3: how to calculate exact distance between two point?
                        JETalmage Community Member

                        Most things in Illustrator are more cumbersome than necessary. Everything in Illustrator is a workaround.

                         

                        JET