Skip to main content
Jesseham-JAh5zI
Participating Frequently
May 9, 2007
Question

Is there a way to calculate the area of a shape?

  • May 9, 2007
  • 23 replies
  • 203224 views
I work in toy packaging and the size of the warning we have to use is dictated by the size of the package. On most items, it's pretty straight forward, LxW... But that doesn't always work, as the packaging isn't always that simple. Is there a way to get Illustrator to give me the area of a shape?

Thanks!

23 replies

Participating Frequently
September 4, 2007
JET:

Wow, talk about service. THAT is exactly what I need.

And you've taught me how to fish -- those are great examples, and I can take the scripting from here if I need any more adjustments, which I probably do not.

Thanks for the recommendation for Canvas, but I should not need to do this kind of task routinely. Once I get a set of values for a total of about 6 geographic areas represented in exactly two aerial photos, I should not need to estimate areas enclosed by paths ever again. All I need is decent estimates of the sizes of these areas -- I'm not looking for perfection, just confirmation of some parameters I already have.

Since you mention it, on a completely different project, I'm working with maps -- tracing old maps of towns Eastern Europe to help understand and document the period between World War I and World War II. (My grandparents were from Old Poland, now Belarus.) In my search through Illustrator add-ins I saw some potentially useful functions that might help with that work.

(Over the course of my professional life, I've definitely seen lots of cases where one is tempted to adapt a particular software tool to a new use, things get out of hand, and one ends up doing things never intended. [To show my age, here's my favorite example: Writing an full-screen editor in the command-line editor TECO.] Almost certainly there are cartographic tools yet more a suited to my mapping tasks -- but I own Illustrator, I'm somewhat adept with its simple functions, and --even if the cartographic software is no- or low-cost, I'm not certain I could learn a radically different software package for that purpose. OK... Enough philosophy, right?)

Thanks!

Henry
JETalmage
Inspiring
September 3, 2007
> ...just enough to get the square points text on the clipboard: that would do it.

Henry,

Download the .zip again from the same link as given above. It now contains an additional script, JET_AreaLabel.jsx. That script works like the first, except that instead of just displaying the area in an alert, it also:

Creates a PointType textFrame centered on the bounding box of the selected path, containing the text of the alert. (You can delete the unwanted units of measure.)

Copies just the value (no additional text) of the area in square points to the clipboard. You can then paste that value into another program. (For example, you could set up an Excel worksheet with cells to calculate the conversion to acres, based on the drawing scale(s) you are using.)

The script uses the app.cut() function new to CS3, so it may not work in earlier versions.

> Worth mentioning: I had _no_ idea of the number and variety of plug-ins available for Illustrator

Also worth mentioning: If this is a frequent kind of work for you, I really don't know why you are doing it in Illustrator. Illustrator's feature set is practically antagonistic toward drawing to scale. For example, you could be doing the same work in Canvas, where you could see both the area and perimeter of the path always displayed right there in the Object Specs, and use live dimension tools--all with values expressed in true-measure at the actual scale you are using in your drawing.

JET
Participant
August 7, 2011

Just wanted to thank you for the script.  Saved the day and a lot of work for me !

Participating Frequently
September 2, 2007
JET:

That is VERY cool!

Hmmm, now, another scripting language to crack...just enough to get the square points text on the clipboard: that would do it.

Thanks VERY much!

Henry
JETalmage
Inspiring
September 1, 2007
This .zip archive contains a script named JET_GetArea. You select a path, call the script from the File>Scripts menu, and the script returns the alert shown:



The same caveats which Teri mentioned about compound and self-crossing paths apply.

Such a script could probably be easily be modified to:
1. Prompt the user for drawing scale.
2. Return the area value in acres, based on that scale.

JET
Participant
May 18, 2010

JET,

I found your post and script for calculating the area of a shape.  Thank you for creating and posting the script.  It's (almost!) exactly what I'm looking for.  I have images over which I've traced multipe polygons (on the order of 40-100 polygons per image) and I'm ultimately trying to calculate the % area of the total image that the polygons cover.  Your script works beautifully, except that with multiple polygons, I am forced to select each polygon individually.  I have approximately 60 images to repeat this process over ...

I have some experience coding in Matlab and C -- is there any way to run a loop (or something) to automate this process and find the area of multiple polygons at one time?  I would really appreciate your help!

Thank you!

Erin

Participating Frequently
August 31, 2007
All:

Thanks for your help.

Just after posting my query I tried to find a utility that would do the job, and the only one I could find that isn't part of a big, costly package is indeed supplied by Telegraphics. (Thanks Telegraphics!) It's called "Patharea". Unfortunately, CS3 isn't yet supported. (I tried the version for CS2 and got a plug-in load error.) so I unzipped my old copy of AI10 and tried with the "Patheara" for that version. It's a tiny bit clunky for my purposes --can't seem to leave its window open and can't copy data from it with cmd-c-- but it is perfectly adequate.

FYI, I'm tracing land plots on existing surveys and drawings. The areas (in acres) of some closed paths can always be determined. I measure a few of these and determine the scale factor for the particular graphic. Then I trace an unknown area-of-interest and apply the scale factor to get acreage value I want. So far, so good: I'm seeing consistency errors typically below 5% on a old survey -- as good as I can expect for tracing plots on a photocopy of a pen-and-ink drawing about 100 years old.

I played with the "secret window" but I didn't discover the trick of clicking near the bottom. Now that I have seen your experiences using this window, I think it will work just fine for me.

Problem solved!

Worth mentioning: I had _no_ idea of the number and variety of plug-ins available for Illustrator. Kid-in-a-candystore!

Thanks!

Henry
Jesseham-JAh5zI
Participating Frequently
August 31, 2007
It works best for me if I copy and paste the shape into a document of it's own, so it's the only thing in the object tree.

Select the shape, open the batcave window, open that window up so you can see all of the info that shows up, click on the object "button," click on "path" right below. It should pop up a whole pile of info, including the area. It seems like sometimes, I click on the wrong thing first and have to start over at the very beginning with a new document.

To get the area in square inches, I divide the "area" by 72 twice. That's right, right? It's not the other point measurement (72.xxx) is it?
Participating Frequently
August 31, 2007
As it said in the prior post, to see the information about a particular object, you have to click on the label for that object in the Object Tree area. It is not necessary that the object be selected, it is simply that selecting the object makes it easier to tell which label is the right one, since it will be bolded.

Notice the label in the screen shot that says "path" and is bold and underlined in the Object Tree area. Also notice the instructions to click on the bold word "path".

If the file has a lot of objects in it, is is often easier to paste a duplicate copy of the path at the top of the top layer, so that it will be the first non-layer object shown in the Object Tree area.
Participant
August 31, 2007
I haven't used it, but the Telegraphics website (http://telegraphics.com.au/sw/) says they have a free plugin that will calculate the area of a path. Might be worth a look.

Martha
rcraighead
Legend
August 31, 2007
That's the way it appeared to me until I clicked "Object Tree" near the bottom of the palette.
Participating Frequently
August 31, 2007
Folks:<br /><br />AI CS3 MacOS iMac Core Duo<br /><br />I also need to measure the area of objects (simple polygons) and I do not have Acrobat, so the only option I can see is the utra-cool "secret programmer's debugging palette". But it doesn't seem to work for me. No matter how many objects are currently selected, it doesn't list anything. Under "Artwork Object" there's nothing but "<no current>" Ideas?<br /><br />It would probably be sufficient for my purpose if there was an constant-area reshaping function...<br /><br />Or... What?<br /><br />TIA,<br /><br />Henry