15 Replies Latest reply: Apr 9, 2015 12:02 PM by alfredeneumanjr RSS

    CS6: Measure a shape’s area?

    Klаus Community Member

      Hi there!

       

      With Illustrator CS6, is there a way to measure/calculate the enclosed area of a given vector shape?

       

      Thanks

      Klaus

        • 1. Re: CS6: Measure a shape’s area?
          Jacob Bugge MVP

          Klaus,

           

          I hope this thread will help you.

           

          http://forums.adobe.com/message/4742474#4742474

          • 2. Re: CS6: Measure a shape’s area?
            Klаus Community Member

            I’ve read that before, but it did not actually help me.

            • 3. Re: CS6: Measure a shape’s area?
              CarlosCanto MVP

              why not? then what is it what you need?

              • 4. Re: CS6: Measure a shape’s area?
                Klаus Community Member

                I need to know if there is a way to measure/calculate the enclosed area of a given vector shape with Illustrator CS6.

                 

                The mentioned thread mainly seems to list methods not compatible with CS6 – plus some sort of scripting approach (?) which is not compatible with me

                • 5. Re: CS6: Measure a shape’s area?
                  Monika Gause MVP

                  Then why don't you just ask how to handle scripts?

                   

                  Copy the line of code into a text document (ASCII), save it as a .jsx in Illustrator program folder > Presets > Scripts, restart Illustrator and select from  File > Scripts.

                  • 6. Re: CS6: Measure a shape’s area?
                    Klаus Community Member

                    Thanks, Monika.

                     

                    Had to alter the code, though, because none of the versions there prompted me with correct millimeter or square millimeter values.

                    • 7. Re: CS6: Measure a shape’s area?
                      CarlosCanto MVP

                      did they know at that time that 3 months later, Klaus was going to need square mm?

                      • 8. Re: CS6: Measure a shape’s area?
                        Klаus Community Member

                        Find it somewhat surprising that such an «area feature» isn’t included in the standard Illustrator features set – the Info window would just be perfect for that.

                        • 9. Re: CS6: Measure a shape’s area?
                          Jacob Bugge MVP

                          Find it somewhat surprising that such an «area feature» isn’t included in the standard Illustrator features set

                           

                          Indeed, Klaus.

                           

                          And it is noteworthy that CS6 is the worst version in terms of hidden solutions and use of ready external means.

                           

                          As a joke you could save the object in question, place it in a new document in 10 (the one before (the first version of) CS), apply the free Patharea filter from Telegraphics, and see the area.

                          • 10. Re: CS6: Measure a shape’s area?
                            VisualAmplitude

                            I'm sorry to be so ignorant, but could someone please provide what precisely needs to be copied into the text document and saved as .jsx (in order to calculate the area of any given vector shape in Adobe Illustrator CS6)? I've tried several variations of the code from the above link, with and without the beginning "alert" and parenthesis, and with or without the closing semicolon, but am always getting a syntax error when I try to launch the script in Illustrator.

                             

                            Thanks for your help.

                            • 11. Re: CS6: Measure a shape’s area?
                              Larry G. Schneider MVP

                              This is the line


                              alert("Area & Length\nArea: " + (app.activeDocument.selection[0].area/5184).toFixed(3) + "\nLength: " + (app.activeDocument.selection[0].length/72).toFixed(3));

                               

                              This is for inches to 3 decimal places.

                               

                              Copy the above and paste into a new window in either the ExtendScript Tool Kit (ESTK found in Applications/Utilities/Adobe Utilities) or in a text editor. If you use the text editor make sure you save it as plain text with a .jsx extension. Place it in the Application/Adobe Illustrator CSX/Presets/en_US/Scripts folder and restart. Open a file, select an object and run the script from File/Scripts.

                              • 12. Re: CS6: Measure a shape’s area?
                                999ducatista

                                so it seems the area script will calculate the area of a simple shape, like a rectangle or a circle, but not a compound shape, or an odd shape like a letter (made with outline) or a donut shape....bummer...still on the hunt myself for this solution in CS6...

                                • 13. Re: CS6: Measure a shape’s area?
                                  alfredeneumanjr

                                  Hi! I also needed the area to be calculated into the metric system. To save some work for others that like me suffers from dyscalculia I publish my effort:

                                  1. See the original script at github: Script to find the area of shapes in Adobe Illustrator

                                  2. Change the divisor from 72 (ppi - pixels per inch) to 2.834645669291 (pixels per millimeter) [pixels acctually being "computer points"].

                                  3. The last two parts of the original script was changed into this:

                                   

                                  // Conversions   

                                    var ppMm = 2.834645669291;

                                    var areaInMm = Math.round((totalArea / ppMm / ppMm) * 100) / 100;

                                    if (areaInMm < 0) var areaInMm = -areaInMm;

                                   

                                    // Display

                                    alert('Shape Area\n' + areaInMm + ' square millimeters \n' + i + ' shapes');

                                  • 14. Re: CS6: Measure a shape’s area?
                                    corpMVMT

                                    None of these work for me, it just keeps giving me a syntax error. Why is this?

                                    • 15. Re: CS6: Measure a shape’s area?
                                      alfredeneumanjr Community Member

                                      It works for me. I think the culprit could be your not saving it as really plain text, just changing the file ending is not enough.

                                      Or that your actually have a syntax error.

                                       

                                      The script is not mine, but I take liberty and attach my version of the entire script below.

                                      But be aware that if you have too many and too complex shapes, the script does not calculate correct at all times.

                                       

                                      Best regards, Alfred.

                                       

                                       

                                       

                                      if (app.documents.length > 0) {

                                       

                                        if (app.activeDocument.selection.length < 1) {

                                        alert('Select a path first');

                                        } else if (app.activeDocument.selection[0].area) {

                                        // Individual Items

                                        var objects =  app.activeDocument.selection;

                                        } else if (app.activeDocument.selection[0].pathItems) {

                                        // Group/Compound Shape

                                        var objects = app.activeDocument.selection[0].pathItems;

                                        } else {

                                        alert('Please select a path or group.');

                                        }

                                       

                                        // Collect info

                                        var totalArea = 0;

                                        for (var i=0; i<objects.length; i++) {

                                        if (objects[i].area) {

                                        var totalArea = totalArea + objects[i].area;

                                        }

                                        }

                                       

                                        // Conversions

                                        var ppCm = 28.34645669291;

                                        var areaInCm = Math.round((totalArea / ppCm / ppCm) * 100) / 100;

                                        if (areaInCm < 0) var areaInCm = -areaInCm;

                                       

                                        // Display

                                        alert('Shape Area\n' + areaInCm + ' square centimeters \n' + i + ' shapes');

                                       

                                      }