<?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: Length Of Object in a selection set in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/length-of-object-in-a-selection-set/m-p/2141216#M76041</link>
    <description>/*&lt;BR /&gt;
hey all,  Working on a .net program that switches to the layout i want and &lt;BR /&gt;
activates the viewport to model space. I have it so the user selects a &lt;BR /&gt;
series of LWpolylines.  I would like to get it to spit out the length of &lt;BR /&gt;
each line.  I just need help getting started, i try doing a selection set &lt;BR /&gt;
but there isnt a length property.&lt;BR /&gt;
*/&lt;BR /&gt;
&lt;BR /&gt;
Did you find out from where Polyline is inherit? - it is from the Curve &lt;BR /&gt;
class - then, have a look into the class members and in there you can use &lt;BR /&gt;
GetDistanceAtParameter(); or GetDistAtPoint() methods.&lt;BR /&gt;
&lt;BR /&gt;
HTH</description>
    <pubDate>Tue, 18 Dec 2007 17:55:11 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2007-12-18T17:55:11Z</dc:date>
    <item>
      <title>Length Of Object in a selection set</title>
      <link>https://forums.autodesk.com/t5/net-forum/length-of-object-in-a-selection-set/m-p/2141215#M76040</link>
      <description>hey all,  Working on a .net program that switches to the layout i want and activates the viewport to model space. I have it so the user selects a series of LWpolylines.  I would like to get it to spit out the length of each line.  I just need help getting started, i try doing a selection set but there isnt a length property.  &lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance&lt;BR /&gt;
Nick</description>
      <pubDate>Tue, 18 Dec 2007 17:07:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/length-of-object-in-a-selection-set/m-p/2141215#M76040</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-12-18T17:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: Length Of Object in a selection set</title>
      <link>https://forums.autodesk.com/t5/net-forum/length-of-object-in-a-selection-set/m-p/2141216#M76041</link>
      <description>/*&lt;BR /&gt;
hey all,  Working on a .net program that switches to the layout i want and &lt;BR /&gt;
activates the viewport to model space. I have it so the user selects a &lt;BR /&gt;
series of LWpolylines.  I would like to get it to spit out the length of &lt;BR /&gt;
each line.  I just need help getting started, i try doing a selection set &lt;BR /&gt;
but there isnt a length property.&lt;BR /&gt;
*/&lt;BR /&gt;
&lt;BR /&gt;
Did you find out from where Polyline is inherit? - it is from the Curve &lt;BR /&gt;
class - then, have a look into the class members and in there you can use &lt;BR /&gt;
GetDistanceAtParameter(); or GetDistAtPoint() methods.&lt;BR /&gt;
&lt;BR /&gt;
HTH</description>
      <pubDate>Tue, 18 Dec 2007 17:55:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/length-of-object-in-a-selection-set/m-p/2141216#M76041</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-12-18T17:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: Length Of Object in a selection set</title>
      <link>https://forums.autodesk.com/t5/net-forum/length-of-object-in-a-selection-set/m-p/2141217#M76042</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
First off state you're version (Ac2008/VS2005...)&lt;BR /&gt;
&lt;BR /&gt;
first off get a ObjectId Array from the selectionset with:&lt;BR /&gt;
&lt;SELECTIONSET&gt;.GetObjectIds()&lt;BR /&gt;
&lt;BR /&gt;
Then loop these ObjectId's and see if there PolyLine object.&lt;BR /&gt;
(use the GetObject methode from the transaction)&lt;BR /&gt;
&lt;BR /&gt;
I myself use TypeOf to determine if it's a PolyLine object.&lt;BR /&gt;
Set it to a Polyline instance, the Polyline Object has a Length property (also Area, etc)&lt;BR /&gt;
&lt;BR /&gt;
Maybe You also can post the code you have so far.&lt;BR /&gt;
I myself have a Palette that evals selectionsets, it shows total Length and Area of closed polylines and Circles, works perfect.&lt;BR /&gt;
&lt;BR /&gt;
A Caddie.&lt;BR /&gt;
(AutoCAD 2008, VS2005, Win XP Pro Sp2)&lt;/SELECTIONSET&gt;</description>
      <pubDate>Tue, 18 Dec 2007 18:33:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/length-of-object-in-a-selection-set/m-p/2141217#M76042</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-12-18T18:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: Length Of Object in a selection set</title>
      <link>https://forums.autodesk.com/t5/net-forum/length-of-object-in-a-selection-set/m-p/2141218#M76043</link>
      <description>Try this one that partially cutted from my project&lt;BR /&gt;
'//&lt;BR /&gt;
Imports Autodesk.AutoCAD.Runtime&lt;BR /&gt;
Imports Autodesk.AutoCAD.EditorInput&lt;BR /&gt;
Imports Autodesk.AutoCAD.DatabaseServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.GraphicsInterface&lt;BR /&gt;
Imports Autodesk.AutoCAD.ApplicationServices.Application&lt;BR /&gt;
Imports AcadRT = Autodesk.AutoCAD.Runtime&lt;BR /&gt;
Imports AcadED = Autodesk.AutoCAD.EditorInput&lt;BR /&gt;
Imports AcadDB = Autodesk.AutoCAD.DatabaseServices&lt;BR /&gt;
Imports AcadApp = Autodesk.AutoCAD.ApplicationServices.Application&lt;BR /&gt;
&lt;BR /&gt;
Public Class Form1&lt;BR /&gt;
'//&lt;BR /&gt;
    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click&lt;BR /&gt;
        Me.Close()&lt;BR /&gt;
    End Sub&lt;BR /&gt;
'//&lt;BR /&gt;
    Private Sub btnSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect.Click&lt;BR /&gt;
        Dim tot As Double = CalcLength()&lt;BR /&gt;
        Me.Label1.Text = "Total Length:"&lt;BR /&gt;
        Me.txtTotal.Text = String.Format("{0}", tot)&lt;BR /&gt;
    End Sub&lt;BR /&gt;
'//&lt;BR /&gt;
    Private Shared Function CalcLength() As Double&lt;BR /&gt;
        Dim tot As Double = 0&lt;BR /&gt;
&lt;BR /&gt;
        Dim ed As Editor = AcadApp.DocumentManager.MdiActiveDocument.Editor&lt;BR /&gt;
&lt;BR /&gt;
        Dim dxf() As TypedValue = {New TypedValue(DxfCode.Start, "LWPOLYLINE")}&lt;BR /&gt;
        Dim filt As New SelectionFilter(dxf)&lt;BR /&gt;
&lt;BR /&gt;
        Dim opts As PromptSelectionOptions = New PromptSelectionOptions&lt;BR /&gt;
        opts.MessageForAdding = "Select polylines to calculate the total length:"&lt;BR /&gt;
        opts.AllowDuplicates = False&lt;BR /&gt;
        opts.SingleOnly = False&lt;BR /&gt;
&lt;BR /&gt;
        Dim res As PromptSelectionResult = ed.GetSelection(opts, filt)&lt;BR /&gt;
        If res.Status &amp;lt;&amp;gt; PromptStatus.OK Then&lt;BR /&gt;
            Return 0&lt;BR /&gt;
        End If&lt;BR /&gt;
&lt;BR /&gt;
        Dim db As Database = HostApplicationServices.WorkingDatabase&lt;BR /&gt;
        Using tr As Transaction = db.TransactionManager.StartTransaction()&lt;BR /&gt;
&lt;BR /&gt;
            Dim sset As SelectionSet = res.Value&lt;BR /&gt;
            Dim IDs() As ObjectId = sset.GetObjectIds&lt;BR /&gt;
            Dim n As Integer = 0&lt;BR /&gt;
            For Each Id As ObjectId In IDs&lt;BR /&gt;
                Dim ent As Entity = tr.GetObject(IDs(n), OpenMode.ForRead)&lt;BR /&gt;
                Dim pl As Polyline = tr.GetObject(ent.ObjectId, OpenMode.ForRead)&lt;BR /&gt;
                Dim ln As Double = pl.GetDistanceAtParameter(pl.EndParam)&lt;BR /&gt;
                tot = tot + ln&lt;BR /&gt;
                n += 1&lt;BR /&gt;
            Next&lt;BR /&gt;
&lt;BR /&gt;
           ' MessageBox.Show(String.Format("Total length = {0}", tot)) ' for debug only&lt;BR /&gt;
&lt;BR /&gt;
            tr.Dispose()&lt;BR /&gt;
        End Using&lt;BR /&gt;
&lt;BR /&gt;
        Return tot&lt;BR /&gt;
&lt;BR /&gt;
    End Function&lt;BR /&gt;
&lt;BR /&gt;
End Class&lt;BR /&gt;
'//&lt;BR /&gt;
&lt;BR /&gt;
~'J'~</description>
      <pubDate>Tue, 18 Dec 2007 20:33:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/length-of-object-in-a-selection-set/m-p/2141218#M76043</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-12-18T20:33:54Z</dc:date>
    </item>
  </channel>
</rss>

