Short description
📏 SumLengthField is an AutoCAD AutoLISP utility for creating live FIELD-based length and area totals from selected drawing objects.
🧮 It helps CAD users calculate combined line lengths, polyline lengths, circle circumferences, hatch areas, region areas, and object areas directly inside MText, table cells, text, attributes, or MLeader annotations.
Command:
🚀 Main commands:
– SumLengthField – creates a total length field using current drawing units.
– SumLengthField_1 – creates a total length field with a 0.001 conversion factor, useful for mm to m workflows.
– SumAreaField – creates a total area field using current drawing units.
– SumAreaField_1 – creates a total area field with a 1e-6 conversion factor, useful for mm² to m² workflows.
– SumLengthField_extended – creates the associative length field and adds extra MText annotations for copied result text and difference text.
Description:
📐 SumLengthField generates associative AutoCAD FIELD expressions from selected geometry and writes the result into the drawing as annotation.
🔄 Because the output is FIELD-based, the displayed length or area can update when referenced objects change, after AutoCAD fields are refreshed.
🧩 The length workflow supports arcs, circles, lines, lightweight polylines, heavy 2D polylines, and 3D polylines.
🟧 The area workflow supports arcs, circles, ellipses, hatches, polylines, regions, and splines. Open objects are evaluated using AutoCAD’s area property behavior.
📝 The result can be inserted as new MText, written into a selected table cell, or pushed into existing Text, MText, Attribute, Attributed Block, or MLeader content.
🧠 For multiple selected objects, the routine builds an AcExpr field that sums all referenced object properties into one displayed total.
🔐 Undo marks are used so the operation can be reverted cleanly inside AutoCAD.
Helper function: (if any)
🧰 Important helper functions included in the project:
– lengthfield – builds the total length or perimeter field expression.
– areafield – builds the total area field expression.
– LM:outputtext – places the field into MText, a table cell, text, attributes, attributed blocks, or MLeader content.
– LM:ssget – wraps AutoCAD selection with a custom prompt.
– LM:getcell – detects table cells from picked points.
– LM:listbox – displays a temporary DCL attribute selector when multiple attributes are available.
– LM:getmleaderattributes and LM:setmleaderattributevalue – read and update MLeader block attributes.
– LM:objectid and LM:intobjectid – generate ObjectID strings used inside AutoCAD FIELD expressions.
– LM:startundo and LM:endundo – manage undo grouping.
Functionalities:
📏 Live length summation from selected linear objects.
🟦 Area summation from closed or area-capable objects.
🔢 Unit conversion command variants for mm to m and mm² to m² workflows.
📌 Output to new MText by picking a point in the drawing.
📊 Output directly into AutoCAD table cells.
🏷️ Output into Text, MText, Attributes, Attributed Blocks, and MLeaders.
🧩 Attribute selector dialog for blocks or MLeaders with multiple editable attributes.
🔄 FIELD expression generation using ObjectID references, AcObjProp, and AcExpr.
🧹 Existing field content is cleared before the new field is written.
🔐 Safe undo handling and locked-layer checks.
Result:
✅ The result is a dynamic annotation workflow for AutoCAD quantity extraction.
📐 Users can place length and area totals directly in drawings, tables, labels, blocks, or leaders without manually calculating totals outside AutoCAD.
🚀 The tool improves drafting speed, quantity checking, BOQ preparation, layer-based measurement workflows, and civil engineering production documentation.
Images, animations etc.
XAML code:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:src="clr-namespace:Autodesk.Windows;assembly=AdWindows"> <src:RibbonToolTip x:Key="SumLengthField"> <src:RibbonToolTip.ExpandedContent> <StackPanel> <TextBlock Background="AntiqueWhite" TextAlignment="Left"> <Bold>Function Syntax: SumLengthField (Current units) / SumLengthField_1 (Current units with 0.001 conversion factor (mm->m))</Bold> <LineBreak/> <Hyperlink>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/length-field-lisp-by-lee-mac-to-modify-gt-old-length-current/m-p/10578203#M56399</Hyperlink> <LineBreak/> <Bold>Program Overview</Bold><LineBreak/> This program offers two commands to allow a user to generate a field expression referencing either the <Bold>area</Bold> or the <Bold>length</Bold>/<Bold>perimeter</Bold>/<Bold>circumference</Bold> of one or more selected objects.<LineBreak/> 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.<LineBreak/> <Bold>Functionalities:</Bold><LineBreak/> • The user may specify: <LineBreak/> – A point at which to create a new multiline text object housing the field expression.<LineBreak/> – A table cell in which the field should be inserted.<LineBreak/> – An existing single-line text, multiline text, multileader, or attribute to be populated with the field expression.<LineBreak/> <Bold>Commands:</Bold><LineBreak/> • <Run Foreground="DarkRed">'SumLengthField'</Run> (<Bold>Sum Length Field</Bold>): Prompts the user to select objects for which to return the length summation.<LineBreak/> – Supported object types: Arcs, Circles, Lines, 2D Polylines (light or heavy), 3D Polylines.<LineBreak/> • <Run Foreground="DarkRed">'SumAreaField'</Run> (<Bold>Sum Area Field</Bold>): Prompts the user to select objects for which to return the area summation.<LineBreak/> – Supported object types: Arcs, Circles, Ellipses, Hatches, 2D Polylines (light or heavy), Regions, Splines.<LineBreak/> – If the selected object is open, the area is computed as though a straight line connects the start point and endpoint.<LineBreak/> <Bold>Insertion Options:</Bold><LineBreak/> • The user is prompted to specify a point or table cell to insert a field expression referencing the summation.<LineBreak/> • The user may also choose the <Run Foreground="DarkRed">'Object'</Run> option to populate an existing annotation object.<LineBreak/> • Supported annotation objects for population:<LineBreak/> – Single-line text (<Bold>DText</Bold>)<LineBreak/> – Multiline text (<Bold>MText</Bold>)<LineBreak/> – Single-line or multiline attribute<LineBreak/> – Attributed block<LineBreak/> – Multileader (<Bold>MLeader</Bold>) with multiline text or attributed block content<LineBreak/> • If the user selects an attributed block or attributed multileader with multiple attributes, a dialog interface lists the available attributes and prompts for the destination.<LineBreak/> <Bold>Additional Features:</Bold><LineBreak/> • The user can predefine the target block/multileader attribute by specifying the attribute tag in the program source code.<LineBreak/> • The resulting field expression displays the sum of lengths or areas of the selected objects, formatted using the field formatting code defined at the top of each command.<LineBreak/> </TextBlock> <!-- Use MediaElement for GIF (static first frame) and Image as fallback --> </StackPanel> </src:RibbonToolTip.ExpandedContent> </src:RibbonToolTip> <src:RibbonToolTip x:Key="SumAreaField"> <src:RibbonToolTip.ExpandedContent> <StackPanel> <TextBlock Background="AntiqueWhite" TextAlignment="Left"> <Bold>Function Syntax: SumAreaField (Current units) / SumAreaField_1 Current units with 1e-6 (0.000001) conversion factor (mm2->m2)</Bold> <LineBreak/> <Hyperlink>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/length-field-lisp-by-lee-mac-to-modify-gt-old-length-current/m-p/10578203#M56399</Hyperlink> <LineBreak/> This program offers two commands to allow a user to generate a field expression referencing either the <Bold>area</Bold> or the <Bold>length</Bold>/<Bold>perimeter</Bold>/<Bold>circumference</Bold> of one or more selected objects.<LineBreak/> 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.<LineBreak/> The user may opt to specify:<LineBreak/> • A point at which to create a new multiline text object housing the field expression.<LineBreak/> • A table cell in which the field should be inserted.<LineBreak/> • An existing single-line text, multiline text, multileader, or attribute to be populated with the field expression.<LineBreak/> Upon issuing the command syntax <Run Foreground="DarkRed">'SumLengthField'</Run> (<Bold>Sum Length Field</Bold>) at the AutoCAD command-line, the program first prompts the user to make a selection of objects for which to return the length summation.<LineBreak/> At this prompt, the user may select any number of <Run Foreground="Blue">Arcs</Run>, <Run Foreground="Blue">Circles</Run>, <Run Foreground="Blue">Lines</Run>, <Run Foreground="Blue">2D Polylines</Run> (light or heavy), or <Run Foreground="Blue">3D Polylines</Run>.<LineBreak/> Alternatively, upon issuing the command syntax <Run Foreground="DarkRed">'SumAreaField'</Run> (<Bold>Sum Area Field</Bold>) at the AutoCAD command-line, the program will prompt the user to make a selection of objects for which to return the area summation.<LineBreak/> At this prompt, the user may select any number of <Run Foreground="Blue">Arcs</Run>, <Run Foreground="Blue">Circles</Run>, <Run Foreground="Blue">Ellipses</Run>, <Run Foreground="Blue">Hatches</Run>, <Run Foreground="Blue">2D Polylines</Run> (light or heavy), <Run Foreground="Blue">Regions</Run>, or <Run Foreground="Blue">Splines</Run>.<LineBreak/> If the selected object is open, the area is computed as though a straight line connects the start point and endpoint.<LineBreak/> 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.<LineBreak/> At this prompt, the user may also choose the <Run Foreground="DarkRed">'Object'</Run> option in order to populate the content of an existing annotation object with the field expression.<LineBreak/> Upon choosing this option, the user may select any:<LineBreak/> • Single-line text (<Bold>DText</Bold>)<LineBreak/> • Multiline text (<Bold>MText</Bold>)<LineBreak/> • Single-line or multiline attribute<LineBreak/> • Attributed block<LineBreak/> • Multileader (<Bold>MLeader</Bold>) with either multiline text or attributed block content<LineBreak/> 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.<LineBreak/> 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.<LineBreak/> 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.<LineBreak/> </TextBlock> <!-- Use MediaElement for GIF (static first frame) and Image as fallback --> </StackPanel> </src:RibbonToolTip.ExpandedContent> </src:RibbonToolTip> </ResourceDictionary>
