Autocad Polyline Length Sum



Type ARX in command line, then Load and pick on GeomProps2006.arx if use Autocad 2006 or GeomProps2007.arx if use Autocad 2007-2009. This operation needs to be made once After that simply choose objects and in a window of properties look the area, volume, length Important!!! AutoCAD Field is a great tool for AutoCAD 2005 or later. Fields are a really nice addition that give you quick access to various types of information via TEXT, MTEXT or an Attribute. You can calculate the length of a single AutoCAD object (Line, Circle, Polyline etc.) with AutoCAD Object Field.

I have a problem hopefully someone might have a workaround that i haven't thought of,here goes! I work for the city of Barcelos (Portugal) in the electrical department, After we conclude the drawing part, we have to sum up all the lighting units and cable that will be needed, for the units i make blocks out of them giving tem reference names (ex. Dorus ) then use qselect to select the blocks and within seconds i get the sum of the blocks that exist in the drawing with that name,easy right, problem comes from the cable part, where i have to convert the lines into polylines then use the length command to get the length then write down on paper and at the end sum it all up to get the final count. I tried to use qselect but in the properties tab length just says 'VARIES' . Is there a way to sum up all the polylines length values to reach a total value, whether it be by qselect, filter, all on the same layer, hell even programing a routine.If anyone can help, i´ll give my word that i´ll put a good word for you in heaven, unless of course i don´t get in but thats a whole new story. Thanks for listening.
Function SyntaxLF (Length Field) / AF (Area Field)
Current Version1.3
DownloadLengthAreaFieldV1-3.lsp
View HTML VersionLengthAreaFieldV1-3.html
Donate
Contents

Program Description

This program offers two commands to allow a user to generate a field expression referencing either the area or the length/perimeter/circumference of one or more selected objects.

In the case of selecting multiple objects, the field expression will reference the sum of the areas or lengths of all objects in the selection.

The user may opt to specify a point at which to create a new multiline text object housing the field expression, pick a table cell in which the field should be inserted, or select an existing single-line text, multiline text, multileader, or attribute to be populated with the field expression.

Length Field

Upon issuing the command syntax LF (Length Field) at the AutoCAD command-line, the program first prompts the user to make a selection of objects for which to return the length summation.

At this prompt, the user may select any number of Arcs, Circles, Lines, 2D Polylines (light or heavy), or 3D Polylines.

Area Field

Alternatively, upon issuing the command syntax AF (Area Field) at the AutoCAD command-line, the program will prompt the user to make a selection of objects for which to return the area summation.

At this prompt, the user may select any number of Arcs, Circles, Ellipses, Hatches, 2D Polylines (light or heavy), Regions, or Splines. If the selected object is open, the area is computed as though a straight line connects the start point and endpoint. Ctrl alt del for mac.

Autocad polyline length sum

Field Output

The user is then prompted to specify a point or table cell to insert a field expression referencing the summation of the lengths or areas of the selected objects.

At this prompt, the user may also choose the 'Object' option in order to populate the content of an existing annotation object with the field expression.

Length

Upon choosing this option, the user may select any single-line text (DText), multiline text (MText), single-line or multiline attribute, attributed block, or multileader (MLeader) with either multiline text or attributed block content.

If the user selects an attributed block or attributed multileader with more than one attribute, the user is presented with a dialog interface listing the available attributes, and is prompted to select a destination for the field expression.

Polyline Command In Autocad

The user may optionally predefine the target block/multileader attribute by specifying the attribute tag where noted at the top of the program source code.

The resulting field expression will display the sum of the lengths or areas of the selected objects, formatted using the field formatting code specified at the top of each command definition.

Custom Commands

The available commands offered by the program are defined at the very top of the program source code. Additional custom commands which target specific attribute tags, or which employ varying field formatting codes may be defined by the user to accommodate drawings in which lengths or areas must be expressed in a variety of formats.

Four custom commands are already defined as examples:

Here, the general format of the definition of a command is:

Here, the <Target-Attribute-Tag> may be the tag name of an attribute reference to be populated with the field expression (such tag is not case-sensitive), or nil if the user is permitted to select any attribute.

For example:

The above custom command may be invoked at the AutoCAD command-line using the syntax mylf and targets an attribute with tag name 'TAG1' with the resulting length formatted:

  • in Decimal Units (%lu2)
  • to a Precision of 3 d.p. (%pr3)
  • with a Prefix of 'Length:' (%ps[Length:,])
  • with a Conversion Factor of 0.1 (%ct8[0.1])

Length / Area Formatting Code

Autocad Add Multiple Polyline Lengths

The field formatting code supplied as the second parameter for each custom command may be altered to display the length or area in a desired format:

To determine the correct formatting code to be used, perform the following steps:

  • Type FIELD at the AutoCAD command-line and press ENTER to open the Field dialog.
  • Select Objects from the 'Field Category' drop-down menu.
  • Select Object from the 'Field Names' section.
  • Select an object (with length or area) from the drawing by clicking the object selection button adjacent to the 'Object Type' box.
  • Select the Length or Area property from the 'Property' panel (or equivalent property for Arcs & Circles).
  • Configure the formatting options as desired.
  • Click OK and pick a point in the drawing to create a temporary MText Field.
  • Download & load my Field Formatting Code program.
  • Type fieldformat to run the program and select the temporary MText Field created earlier.
  • Following a valid selection, the field formatting code will be printed to the command-line, e.g.:
Total length command autocad

For more examples & information on how to supply a field formatting code to a custom command, please refer to the program page for my Quick Field program.

Instructions for Running

Autocad Polyline Length Summer

Please refer to How to Run an AutoLISP Program.