Copy link to clipboard
Copied
Hi there!
With Illustrator CS6, is there a way to measure/calculate the enclosed area of a given vector shape?
Thanks
Klaus
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I’ve read that before, but it did not actually help me.
Copy link to clipboard
Copied
why not? then what is it what you need?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thanks, Monika.
Had to alter the code, though, because none of the versions there prompted me with correct millimeter or square millimeter values.
Copy link to clipboard
Copied
did they know at that time that 3 months later, Klaus was going to need square mm?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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');
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
None of these work for me, it just keeps giving me a syntax error. Why is this?
Copy link to clipboard
Copied
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.area) {
var totalArea = totalArea + objects.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');
}