How to Sum the Lengths of Multiple 2D Polylines?

Has anyone created a script that will add up and display the linear footage of multiple polylines? I often find myself needing to add up the lengths of many different polylines that represent curb and gutter. It would be great to have a script that would tell me the total LF of all the polylines displayed on my screen at a given time or the total LF of all the polylines in a given layer. Thanks!

I think Dynamo is a little overkill for this. A simple LISP is probably a better option. There are lots of them out there, but here’s a starting point.

1 Like

I agree with Zachri,

If you’re just looking for something to quickly grab lengths and areas while in AutoCAD I would suggest LISP commands. I’ve attached tlen.lsp and totalarea.lsp files. These can help when trying to quickly find areas and lengths. You will need to save these text files as .lsp files.

If you’re looking more for report generation in excel or more complex operations I would suggest dynamo. Otherwise LISP is the way to go.

tlen.txt (1021 Bytes) Totalarea.txt (999 Bytes)

1 Like

@mzjensen I disagree, being able to do something in Dynamo (even if for you that have already acquired some experience with it, it might seem trivial), enables to connect workflows (e.g. send that total value to Excel, writing it into a text, assign it as a property set, etc. as suggested by @WrightEngineering).

Even the longest walk starts with the first step.

Looking ahead, the capability of extracting a property from similar objects and sum them up is one of many that is required to drive generative design workflows (e.g. select a parking lot configuration that maximises the park stalls whilst minimizing the curbs length).

You make a valid point, LISP could cut it, but where is the innovation in that?
Please, next time do not dismiss too quickly the request of a fellow forum member (especially if it is the first time they manage to collect the courage to post their first question, welcome @bfiebs!), remember where you started from and be mentors, you make a great one.

SumPolylineLengths.dyn (24.8 KB)


Good point Paolo. It seems like doing almost any task in an environment like Dynamo allows for an unparalleled expand-ability, versatility, and a big push towards generative design. Not to mention it’s much easier to code in than LISP in my opinion! Even just seeing this discussion has sparked some ideas regarding automation of my early cost estimations. Thanks for posting the .dyn and welcome to the forum @bfiebs !

1 Like

Thanks for calling me out @Paolo_Emilio_Serra1. You make fair points that I can’t argue with!

@bfiebs, apologies for sounding dismissive. Have you tried the Dynamo Player? This could allow you to run your script without even opening Dynamo.


Sorry but after gettign that list how can Dynamo print it as a table in the model space? I’m trying lo tearn Dynamo and I kinda get the graph but I would like to know how to print it. Thank you.

I’ve never created a table in Civil 3D with Dynamo and can’t seem to find any nodes for this. One thing you can do though, if you have excel, is export the data to excel and then just copy it and “paste special” into autocad as an AutoCAD entity. Not fully automated but just takes a second. If anyone knows anything about table creation in AutoCAD and would like to contribute that would be awesome.

the easiest way for me is to use DATAEXTRACTION command. Just select what you want to extract.