How to automatically calculate area of multiple closed polylines?

How to automatically calculate area of multiple closed polylines?

knuwan
Enthusiast Enthusiast
21,659 Views
48 Replies
Message 1 of 49

How to automatically calculate area of multiple closed polylines?

knuwan
Enthusiast
Enthusiast

I have this hundreds of closed polylines in different layers.Now I want to calculate the total area for each object/layer type.I would be nice if I have a dynamic table containing the data.

* I dont want to use "Area" cmd and select each PL

*I dont want to create parcels.

 

Any suggestions?

Thanks.

Accepted solutions (3)
21,660 Views
48 Replies
Replies (48)
Message 21 of 49

jae.kwon
Collaborator
Collaborator

It's true that DE tables are great. There are certain things that I don't think it can do (please correct if I'm wrong), like telling you which lot a specific asphalt area belongs to.

0 Likes
Message 22 of 49

Joe-Bouza
Mentor
Mentor

Layering

Joe Bouza
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
Message 23 of 49

Joe-Bouza
Mentor
Mentor

Yes you can if you organize your drawing 

Joe Bouza
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
Message 24 of 49

Joe-Bouza
Mentor
Mentor

Hello Jae

LAYERS

LOT-01-OVERALL

LOT-01-ASPHALT

LOT-01-BLDG-PAD

LOT-02-YADA YADA

 

And so on

 

Joe Bouza
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
Message 25 of 49

knuwan
Enthusiast
Enthusiast

your solution calculate areas for all the polylines as a whole.

In your method I think I should turn ON and OFF layers and select one layer group at a time right? 

what if I add more objects to the drawing?  ( sorry I'm a very basic user)

0 Likes
Message 26 of 49

knuwan
Enthusiast
Enthusiast

How to set "Area ID"?

How to run Dynamo player?

sorry I'm very basic 🙂

 

0 Likes
Message 27 of 49

knuwan
Enthusiast
Enthusiast

I worked on your solution. And got the the data into a table. Is there a way to add a cell to the table and get the sum of layer x ?

Thanks!

0 Likes
Message 28 of 49

ChicagoLooper
Mentor
Mentor

Just like using Excel, you can insert a formula into a cell.

 

100.png

 

 

101.png

Chicagolooper

EESignature

Message 29 of 49

RonaldBrañez
Advocate
Advocate
Accepted solution

It is not necessary to turn layers on or off, C3D recognizes them even if they are turned off. So that you know which layer it corresponds to, you must select the layers property

de1.png

In the next window something like this will appear (The names in the last column correspond to the element's layer)

de2.png


To get the sum by layers:
With the right mouse button on the "Area" heading, find Combine Record Mode> Sum Values.

RonaldBrañez_0-1612211406073.png

 

As you can see, even the counter is updated, having in the column "Area" the sum by layers. You can also create columns of formulas, which allow you to do operations with the elements of the same row.

de4.png

 

Another option is that you add the Total sum of the column "Area",de6.PNG

but to be able to identify the total by layers, you should also insert filters.

de7.PNG

Then you configure the rest of the DE windows, until the process is finished.

To Update (if you increase or remove polygons):
If you increase or remove an element that corresponds to any layer (in the example: Layer1 - 3), you can select the table you entered and with the right mouse button select Update Table Data Links. And if you want you can export it to a file type * .csv

RonaldBrañez_1-1612211439261.png

 

If the answer was useful, don't forget to mark it as accepted and give it a like.

Message 30 of 49

ChicagoLooper
Mentor
Mentor

You can also use the command MAPEXPORT and export your existing parcels to shapefile format. The shapefile, when brought into your drawing, has a Table View. You can copy cells then past them into Excel. Once pasted, you can edit in Excel any way you wish. For example, total sq ft for parcels 1 thru 12 and total sq ft for parcels 13 thru 21, average sq footage for all parcels, parcels larger than 6700 sq ft, etc., etc. etc. See Image-1.

Image-1. Cell contents copied from Table View then pasted to Excel.Image-1. Cell contents copied from Table View then pasted to Excel.

 

When connected using the DATA CONNECT palette, the shapefile parcels will look like this. See Image-2.

Image-2. The parcels have been exported to shapefile.Image-2. The parcels have been exported to shapefile.

 

You can customize the appearance of the shapefile boundaries, e.g. delete the blue fill. You can also label the parcels using the shapefile's DATABASE, e.g. Parcel ID and AREA. See Image-3.

Image-3. Parcel appearance has been customized. The data was taken from the shapefile and used as a label source.Image-3. Parcel appearance has been customized. The data was taken from the shapefile and used as a label source.

 

In a new drawing, you can also use MAPIMPORT command to import the newly created parcel shapefile. The result of this import will be regular AutoCad polygons. You can also, import the labels. The imported labels will be converted from ESRI labels to regular AutoCad mtext. See Image-4.

Image-4. AutoCad polygons and mtext labels. There are no ESRI entities in this drawing.Image-4. AutoCad polygons and mtext labels. There are no ESRI entities in this drawing.

 

FOR ADVANCED USERS:

  1. In step 1, the data collected was taken from the original AutoCad polygonal parcels, i.e. Area, Centroid, Layer, and Length. This 'DATA' is consistent with the polygonal 'Properties' shown in the AutoCad Properties Palette. The FeatId (or Parcel ID) is not from the Properties Palette but was automatically generated during the MapExport procedure.
  2. In step 3 the blue fill was deleted and the parcel borders were modified from black to orange. The cyan labels were customized. In this example only Parcel ID and Area was added to the label. The customization entailed a label with two lines: ID on top and Area at the bottom. The area was further customized by rounding down to two decimals. The customization is global, not individual.
  3. In step 4, the shapefile was converted to polygonal entities and the labels converted to mtext. The labels are consistent with the Excel table shown in image-1. The borders and labels are each on their own AutoCad layer and are now subject to ByLayer behavior. 
  4. If you wish, you could enhance the drawing by adding a second shapefile to display each building footprint. You could then add another label for the the building square footage. Image 4 could also accomodate another polygonal entity for the building and this polygonal footprint would accurately appear inside each parcel. 

 

 

Chicagolooper

EESignature

Message 31 of 49

Joe-Bouza
Mentor
Mentor

In the DE wizard page 5 or 8 you can add a totals footer as well as formula cols to do any conversion / math desired

Joe Bouza
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

Message 32 of 49

tcorey
Mentor
Mentor

This will report, to the command line, the total area of polylines in your selection set.

(defun c:des_PlineMultiAreasTotal ( / pls cbt ctr ttk ok ar )

(vl-load-com)
(prompt "\nSelect Polylines: ")
(setq pls (ssget)
	  cnt (sslength pls)
	  ctr 0
	  ttl 0.000)
	  
	  (while (< ctr cnt)
		(setq pl (vlax-ename->vla-object (ssname pls ctr)))
		(setq ar (vlax-get pl 'Area))
		(setq ttl (+ ttl ar))
		(setq ctr (1+ ctr))
		)
		
		(prompt (strcat "\nTotal area of selected polylines is " (rtos ttl 2 3) " SF"))
		(princ)
		)



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Platinum Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
Message 33 of 49

knuwan
Enthusiast
Enthusiast

Thank you everyone for your help!

0 Likes
Message 34 of 49

jae.kwon
Collaborator
Collaborator

First, remember to close all other drawings - this way Dynamo doesn't get confused what drawing you want to run the script on.

 

Also remember to copy in the drawing objects into the DWG provided (property sets are saved in the drawing and you'll need the "Area ID" property set that's in that drawing for the Dynamo script.

 

Finally, the whole point of this script is not only to get individual areas and layer area totals, but also to 1) have a column in the spreadsheet that tells you exactly which object each number is reporting (by its handle) and also 2) which lot each area "belongs to", identifiable by its handle. (This is the part that I didn't know how to do in DE table method).

 

Give it a try. I think you will find that it's easy to get results with minimal setup.

 

Please also accept as solution if it works for you.

 

adding property set to objectsadding property set to objects

opening dynamo script via dynamo playeropening dynamo script via dynamo player

 

adjust options before running scriptadjust options before running script

Message 35 of 49

knuwan
Enthusiast
Enthusiast

why my property set icon is disabled?(shown in your fig 2)  I have selected polyline and its a closed polyline.And this Dynamo player,does it come with C3D 2021? I use 2020

0 Likes
Message 36 of 49

knuwan
Enthusiast
Enthusiast

I updated to 2021 version with Dynamo player 🙂

But still the icon is disabled(see fig)

0 Likes
Message 37 of 49

jae.kwon
Collaborator
Collaborator
Accepted solution

I'm thinking the property set definition is missing from the drawing...

 

Is that the drawing provided (PolylineAreas.dwg)? There is a property set definition in that drawing that you will need. Two options:

 

1. copy the polylines into PolylineAreas.dwg or..

2. apply the property set to a polyline in PolylineAreas.dwg (if it hasn't been done already) and copy that line into your drawing of choice.

 

Just in case there was a problem with the drawing I uploaded earlier, I'll attach it again to this post.

Message 38 of 49

knuwan
Enthusiast
Enthusiast

I'm on my own template.not the one you sent me.I will check it on your file.

0 Likes
Message 39 of 49

knuwan
Enthusiast
Enthusiast
wow! It worked! Thank you very much!
0 Likes
Message 40 of 49

knuwan
Enthusiast
Enthusiast
Is there a place to get scripts to use with Dynamo?
0 Likes