<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Total Length of Selected Objects in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/6920861#M32460</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, thanks for sharing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;If I may have some suggestions:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;You should use a &lt;A href="http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-D9FB23AE-D853-4D00-A910-4F66FCC4607A" target="_blank"&gt;selection filter&lt;/A&gt; to get only measurable entities.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;You do not need to test the existence of an implied selection set, CommandFlags.UsePickSet will do all the magic (including the selection filter).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class=""&gt;Optionally, you can also use Linq to process the selection set in a more declarative way.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using System.Linq;
using AcAp = Autodesk.AutoCAD.ApplicationServices.Application;

[assembly: CommandClass(typeof(TotalLength.Commands))]

namespace TotalLength
{
    public class Commands
    {
        [CommandMethod("TOTLEN", CommandFlags.UsePickSet)]
        public void TotalLength()
        {
            var doc = AcAp.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;

            // build a selection filter to get only measurable entities
            var filter = new SelectionFilter(new[]
            {
                new TypedValue(-4, "&amp;lt;OR"),
                new TypedValue(0, "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,SPLINE"),
                new TypedValue(-4, "&amp;lt;AND"),
                new TypedValue(0, "POLYLINE"), // polylines 2d or 3d
                new TypedValue(-4, "&amp;lt;NOT"), // but not meshes
                new TypedValue(-4, "&amp;amp;"),
                new TypedValue(70, 112),
                new TypedValue(-4, "NOT&amp;gt;"),
                new TypedValue(-4, "AND&amp;gt;"),
                new TypedValue(-4, "OR&amp;gt;")
            });

            var selection = ed.GetSelection(filter);
            if (selection.Status != PromptStatus.OK)
                return;

            using (var tr = db.TransactionManager.StartTransaction())
            {
                // use Linq queries to get lengths by type in a dictionary
                var lengthes = selection.Value
                    .Cast&amp;lt;SelectedObject&amp;gt;()
                    .Select(so =&amp;gt; (Curve)tr.GetObject(so.ObjectId, OpenMode.ForRead))
                    .ToLookup(curve =&amp;gt; curve.GetType().Name,                         // &amp;lt;- key selector
                              curve =&amp;gt; curve.GetDistanceAtParameter(curve.EndParam)) // &amp;lt;- element selector
                    .ToDictionary(group =&amp;gt; group.Key,    // &amp;lt;- key selector
                                  group =&amp;gt; group.Sum()); // &amp;lt;- element selector

                // print results
                foreach (var entry in lengthes)
                {
                    ed.WriteMessage($"\n{entry.Key,-12} = {entry.Value,9:0.00}");
                }
                ed.WriteMessage($"\nTotal Length = {lengthes.Values.Sum(),9:0.00}");

                tr.Commit();
            }
            AcAp.DisplayTextScreen = true;
        }
    }
}
&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 04 Mar 2017 14:25:31 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2017-03-04T14:25:31Z</dc:date>
    <item>
      <title>Total Length of Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/6916755#M32458</link>
      <description>&lt;P&gt;Hey there everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am brand new to the forum - at least posting wise. &amp;nbsp;I have found the answer to many a quesiton on here before. &amp;nbsp;I work primarily in Civil 3D, but am exploring the creation of custom commands in c#.NET. &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am trying to write a command that when run, asks the user to make a selection on screen, click enter, and it gives the total length of all selected objects. &amp;nbsp;I can get the basic understanding of c#, but have never worked with the Autodesk API's. &amp;nbsp;I have a github repository that I have stored my current code in and I am wondering if I could get some guidance on it from you, the community. &amp;nbsp;Thanks so much for your help! (please be gentle, haha)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/BenKaiser12/TOTLEN" target="_blank"&gt;https://github.com/BenKaiser12/TOTLEN&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 20:55:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/6916755#M32458</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-02T20:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Total Length of Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/6920500#M32459</link>
      <description>&lt;P&gt;Hey y'all&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got the command working. &amp;nbsp;The correct version is posted on github. &amp;nbsp;Feel free to go grab it and give it a try. &amp;nbsp;If you like it, let me know! &amp;nbsp;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/BenKaiser12/TOTLEN" target="_self"&gt;Total Length Visual Studio Project&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2017 04:14:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/6920500#M32459</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-04T04:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Total Length of Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/6920861#M32460</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, thanks for sharing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;If I may have some suggestions:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;You should use a &lt;A href="http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-D9FB23AE-D853-4D00-A910-4F66FCC4607A" target="_blank"&gt;selection filter&lt;/A&gt; to get only measurable entities.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;You do not need to test the existence of an implied selection set, CommandFlags.UsePickSet will do all the magic (including the selection filter).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class=""&gt;Optionally, you can also use Linq to process the selection set in a more declarative way.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using System.Linq;
using AcAp = Autodesk.AutoCAD.ApplicationServices.Application;

[assembly: CommandClass(typeof(TotalLength.Commands))]

namespace TotalLength
{
    public class Commands
    {
        [CommandMethod("TOTLEN", CommandFlags.UsePickSet)]
        public void TotalLength()
        {
            var doc = AcAp.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;

            // build a selection filter to get only measurable entities
            var filter = new SelectionFilter(new[]
            {
                new TypedValue(-4, "&amp;lt;OR"),
                new TypedValue(0, "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,SPLINE"),
                new TypedValue(-4, "&amp;lt;AND"),
                new TypedValue(0, "POLYLINE"), // polylines 2d or 3d
                new TypedValue(-4, "&amp;lt;NOT"), // but not meshes
                new TypedValue(-4, "&amp;amp;"),
                new TypedValue(70, 112),
                new TypedValue(-4, "NOT&amp;gt;"),
                new TypedValue(-4, "AND&amp;gt;"),
                new TypedValue(-4, "OR&amp;gt;")
            });

            var selection = ed.GetSelection(filter);
            if (selection.Status != PromptStatus.OK)
                return;

            using (var tr = db.TransactionManager.StartTransaction())
            {
                // use Linq queries to get lengths by type in a dictionary
                var lengthes = selection.Value
                    .Cast&amp;lt;SelectedObject&amp;gt;()
                    .Select(so =&amp;gt; (Curve)tr.GetObject(so.ObjectId, OpenMode.ForRead))
                    .ToLookup(curve =&amp;gt; curve.GetType().Name,                         // &amp;lt;- key selector
                              curve =&amp;gt; curve.GetDistanceAtParameter(curve.EndParam)) // &amp;lt;- element selector
                    .ToDictionary(group =&amp;gt; group.Key,    // &amp;lt;- key selector
                                  group =&amp;gt; group.Sum()); // &amp;lt;- element selector

                // print results
                foreach (var entry in lengthes)
                {
                    ed.WriteMessage($"\n{entry.Key,-12} = {entry.Value,9:0.00}");
                }
                ed.WriteMessage($"\nTotal Length = {lengthes.Values.Sum(),9:0.00}");

                tr.Commit();
            }
            AcAp.DisplayTextScreen = true;
        }
    }
}
&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2017 14:25:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/6920861#M32460</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-03-04T14:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: Total Length of Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/6920970#M32461</link>
      <description>&lt;P&gt;&amp;nbsp;Hey there&amp;nbsp;&lt;SPAN&gt;Gilles, Thanks for the reply and suggestions!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Would you mind if I asked a couple of questions? &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1. Why use 'var' instead of the type? &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2. in the selection filter, what do the -4, 0, and 70 mean?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3. &amp;nbsp;I have never used LINQ, can you point me in the direction of a good resource to learn it?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for the help!!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2017 16:02:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/6920970#M32461</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-03-04T16:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: Total Length of Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/6921068#M32462</link>
      <description>&lt;P&gt;1. Because&amp;nbsp;&lt;STRONG&gt;&lt;A href="https://msdn.microsoft.com/en-us/library/bb384061.aspx" target="_blank"&gt;var&lt;/A&gt;&lt;/STRONG&gt; is shorter to type than most explicit types and give the same result. Furthemore, IMO, it makes the code more readable (avoiding redundancy as: SelectionFilter filter = new SelectionFilter()). Using inferred type is also an F# habit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Using the int values of the DxfCode enum in selection filters is a old AutoLISP habit.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;-4 stands for: (int)DxfCode.Operator and is used with &lt;STRONG&gt;&lt;A href="http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-04B8192E-B0D8-4731-A882-AE92B7CFAE22" target="_blank"&gt;relational operators and logical grouping operators&lt;/A&gt;&lt;/STRONG&gt;.&lt;/LI&gt;
&lt;LI&gt;0 stands for: (int)DxfCode.Start and is used with &lt;STRONG&gt;&lt;A href="http://help.autodesk.com/view/ACD/2017/ENU/?guid=GUID-7D07C886-FD1D-4A0C-A7AB-B4D21F18E484" target="_blank"&gt;entities DXF names&lt;/A&gt;&lt;/STRONG&gt;.&lt;/LI&gt;
&lt;LI&gt;70 stands for (int)DxfCode.Int16 and is typically used for bit flags, for the&lt;STRONG&gt; &lt;A href="http://help.autodesk.com/view/ACD/2017/ENU/?guid=GUID-ABF6B778-BE20-4B49-9B58-A94E64CEFFF3" target="_blank"&gt;POLYLINE DXF type&lt;/A&gt;&lt;/STRONG&gt; it specifies the polyline type.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;3. &lt;STRONG&gt;&lt;A href="https://msdn.microsoft.com/en-us/library/bb397933.aspx" target="_blank"&gt;Getting started with LINQ in C#&lt;/A&gt;&lt;/STRONG&gt; may be a good start. Within AutoCAD we mostly use &lt;STRONG&gt;&lt;A href="https://msdn.microsoft.com/en-us/library/mt693052.aspx" target="_blank"&gt;LINQ to Objects&lt;/A&gt;&lt;/STRONG&gt; with AutoCAD collections. By my side, I prefer use the &lt;STRONG&gt;&lt;A href="https://msdn.microsoft.com/en-us/library/bb397947.aspx" target="_blank"&gt;Method Syntax&lt;/A&gt;&lt;/STRONG&gt; with &lt;STRONG&gt;&lt;A href="https://msdn.microsoft.com/en-us/library/9eekhta0.aspx" target="_blank"&gt;IEnumerable&amp;lt;T&amp;gt; extension methods&lt;/A&gt;&lt;/STRONG&gt; and &lt;STRONG&gt;&lt;A href="https://msdn.microsoft.com/en-us/library/bb397687.aspx" target="_blank"&gt;lambda expressions&lt;/A&gt;&lt;/STRONG&gt; (again my functional programming background with LISP and F#).&lt;/P&gt;</description>
      <pubDate>Sat, 04 Mar 2017 17:26:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/6921068#M32462</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-03-04T17:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Total Length of Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/9215762#M32463</link>
      <description>&lt;P&gt;hey if you guys are still around. i am trying to put this program in vb.net. the program wont go past the "cast" part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i converted it from c# using online converter, tried several and found one that's decent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using tr = db.TransactionManager.StartTransaction()&lt;BR /&gt;Dim lengths = selection.Value.Cast(Of SelectedObject)().[Select](Function(so) CType(tr.GetObject(so.ObjectId, OpenMode.ForRead), Curve)).ToLookup(Function(curve) curve.[GetType]().Name, Function(curve) curve.GetDistanceAtParameter(curve.EndParam)).ToDictionary(Function(group) group.Key, Function(group) group.Sum())&lt;/P&gt;&lt;P&gt;For Each entry As Object In lengths&lt;BR /&gt;ed.WriteMessage($"\n{entry.Key} = {entry.Value}")&lt;BR /&gt;Next&lt;/P&gt;&lt;P&gt;ed.WriteMessage($"\nTotal Length = {lengths.Values.Sum()}")&lt;BR /&gt;tr.Commit()&lt;BR /&gt;End Using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i completely don't understand that whole lengths = line. maybe that's the linq : )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;pretty interesting how you go through all the object types with one line of code. i would normally write it out case by case.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 21 Dec 2019 23:26:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/9215762#M32463</guid>
      <dc:creator>wang890</dc:creator>
      <dc:date>2019-12-21T23:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: Total Length of Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/9215893#M32464</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not very comfortable with VB but it seems to me the issue is due to the way the converter converted the typedValue array initialisation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;try this way (not tested)&lt;/P&gt;
&lt;PRE&gt;Public Sub TotalLength()
    Dim doc = AcAp.DocumentManager.MdiActiveDocument
    Dim db = doc.Database
    Dim ed = doc.Editor
    Dim filter = New SelectionFilter(New TypedValue() { _
	New TypedValue(-4, "&amp;lt;OR"), _ 
	New TypedValue(0, "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,SPLINE"), _ 
	New TypedValue(-4, "&amp;lt;AND"), _
	New TypedValue(0, "POLYLINE"), _
	New TypedValue(-4, "&amp;lt;NOT"), _
	New TypedValue(-4, "&amp;amp;"), _
	New TypedValue(70, 112), _
	New TypedValue(-4, "NOT&amp;gt;"), _
	New TypedValue(-4, "AND&amp;gt;"), _
	New TypedValue(-4, "OR&amp;gt;") })
    Dim selection = ed.GetSelection(filter)
    If selection.Status &amp;lt;&amp;gt; PromptStatus.OK Then Return

    Using tr = db.TransactionManager.StartTransaction()
        Dim lengthes = selection.Value _
			.Cast(Of SelectedObject)() _
			.Select(Function(so) CType(tr.GetObject(so.ObjectId, OpenMode.ForRead), Curve)) _
			.ToLookup(Function(curve) curve.GetType().Name, Function(curve) curve.GetDistanceAtParameter(curve.EndParam)) _
			.ToDictionary(Function(group) group.Key, Function(group) group.Sum())

        For Each entry In lengthes
            ed.WriteMessage($"\n{entry.Key} = {entry.Value}")
        Next

        ed.WriteMessage($"\nTotal Length = {lengthes.Values.Sum()}")
        tr.Commit()
    End Using

    AcAp.DisplayTextScreen = True
End Sub&lt;/PRE&gt;
&lt;P&gt;Anyway, the use of an online converter and copy / paste without trying to understand the code does is the worst way to learn.&lt;/P&gt;
&lt;P&gt;You should re-write the code to suit your coding conventions or habits.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Dec 2019 08:07:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/9215893#M32464</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-12-22T08:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: Total Length of Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/9217736#M32465</link>
      <description>&lt;P&gt;still getting this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;System.MissingMemberException: 'Public member 'Cast' on type 'SelectionSetDelayMarshalled' not found.'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there a way to put a lisp file in vb.net and add that command? i have this request to put in the total length lisp that you can download on the internet and put into another program with a lot of commands.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 20:28:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/9217736#M32465</guid>
      <dc:creator>wang890</dc:creator>
      <dc:date>2019-12-23T20:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: Total Length of Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/9217827#M32466</link>
      <description>&lt;P&gt;Did you add an 'Import System.Linq' statement to your file?&lt;/P&gt;
&lt;P&gt;Mixing LISP and .NET is much more complex and much less reliable than simply make this code work.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Dec 2019 21:46:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/9217827#M32466</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-12-23T21:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: Total Length of Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/9218229#M32467</link>
      <description>&lt;P&gt;Working solution (tested with AutoCAD 2017)&lt;/P&gt;
&lt;P&gt;The Compile Options settings:&lt;/P&gt;
&lt;P&gt;Explicit = On&lt;/P&gt;
&lt;P&gt;Strict = On&lt;/P&gt;
&lt;P&gt;Infer = On&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Runtime

Public Class Commands
    &amp;lt;CommandMethod("TOTLEN", CommandFlags.UsePickSet)&amp;gt;
    Public Sub TotalLength()
        Dim doc = Application.DocumentManager.MdiActiveDocument
        Dim db = doc.Database
        Dim ed = doc.Editor
        Dim filter = New SelectionFilter(New TypedValue() {
            New TypedValue(-4, "&amp;lt;OR"),
            New TypedValue(0, "ARC,CIRCLE,ELLIPSE,LINE,LWPOLYLINE,SPLINE"),
            New TypedValue(-4, "&amp;lt;AND"),
            New TypedValue(0, "POLYLINE"),
            New TypedValue(-4, "&amp;lt;NOT"),
            New TypedValue(-4, "&amp;amp;"),
            New TypedValue(70, 112),
            New TypedValue(-4, "NOT&amp;gt;"),
            New TypedValue(-4, "AND&amp;gt;"),
            New TypedValue(-4, "OR&amp;gt;")})
        Dim selection = ed.GetSelection(filter)
        If selection.Status &amp;lt;&amp;gt; PromptStatus.OK Then Return

        Using tr = db.TransactionManager.StartTransaction()
            Dim lengthes = selection.Value _
                .Cast(Of SelectedObject)() _
                .Select(Function(so) CType(tr.GetObject(so.ObjectId, OpenMode.ForRead), Curve)) _
                .ToLookup(Function(curve) curve.GetType().Name, Function(curve) curve.GetDistanceAtParameter(curve.EndParam)) _
                .ToDictionary(Function(group) group.Key, Function(group) group.Sum())

            For Each entry In lengthes
                ed.WriteMessage($"{vbLf}{entry.Key} = {entry.Value}")
            Next

            ed.WriteMessage($"{vbLf}Total Length = {lengthes.Values.Sum()}")
            tr.Commit()
        End Using

        Application.DisplayTextScreen = True
    End Sub
End Class&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Dec 2019 06:30:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/9218229#M32467</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-12-24T06:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: Total Length of Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/9228762#M32468</link>
      <description>&lt;P&gt;thank you so much for this. this is it, works perfectly in 2020 too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i turned on the other 2 except explicit. like 160 errors if i turn that on. some lousy declarations and casts there haha.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2020 05:10:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/9228762#M32468</guid>
      <dc:creator>wang890</dc:creator>
      <dc:date>2020-01-03T05:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: Total Length of Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/9250391#M32469</link>
      <description>&lt;P&gt;hey&lt;/P&gt;&lt;P&gt;so now i'm asked to have each object type total length listed separately as one line in the message box, then followed by the total of all objects like before.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i think that's quite a bit extra work yeah?&amp;nbsp; have to do a select case somehow?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 18:56:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/9250391#M32469</guid>
      <dc:creator>wang890</dc:creator>
      <dc:date>2020-01-14T18:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: Total Length of Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/9676947#M32470</link>
      <description>&lt;P&gt;I love method syntax too,&lt;/P&gt;&lt;P&gt;It give us more shorter sentence and data sorting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Aug 2020 14:39:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/9676947#M32470</guid>
      <dc:creator>genosyde</dc:creator>
      <dc:date>2020-08-06T14:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: Total Length of Selected Objects</title>
      <link>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/11524517#M32471</link>
      <description>Hey, i am revisiting this program again and i want to add in civil 3d feature line. do you think you can point me to how to add that in? after 3 years i still don't know how the whole syntax work on this program. didn't program much but i can still figure out most things except this one : )&lt;BR /&gt;&lt;BR /&gt;so i just want to add civil 3d feature lines together and get a total length from it's lengh property.</description>
      <pubDate>Wed, 02 Nov 2022 05:05:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/total-length-of-selected-objects/m-p/11524517#M32471</guid>
      <dc:creator>wang890</dc:creator>
      <dc:date>2022-11-02T05:05:03Z</dc:date>
    </item>
  </channel>
</rss>

