<?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: Find nearest polyline with block in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/find-nearest-polyline-with-block/m-p/3692040#M52633</link>
    <description>&lt;P&gt;I think in this case you an to gather the points along the polyline route&lt;/P&gt;&lt;P&gt;with small steps between,then&amp;nbsp;gather them all in the point3dcollection&lt;/P&gt;&lt;P&gt;to perform the &amp;nbsp;window selection&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Nov 2012 14:04:44 GMT</pubDate>
    <dc:creator>Hallex</dc:creator>
    <dc:date>2012-11-08T14:04:44Z</dc:date>
    <item>
      <title>Find nearest polyline with block</title>
      <link>https://forums.autodesk.com/t5/net-forum/find-nearest-polyline-with-block/m-p/3690680#M52629</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using VB.NET to write a routine that autmatically calculates the area of the polyline nearest to a block (the pline surrounds the block) an then adds the area to the blocks attribute.&lt;/P&gt;&lt;P&gt;I managed to write the program to do this manually for a selected pline and block.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I automatically select a pline nearest to the selected blocks' insertion point?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Help is much appreciated..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2012 16:24:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/find-nearest-polyline-with-block/m-p/3690680#M52629</guid>
      <dc:creator>wouter</dc:creator>
      <dc:date>2012-11-07T16:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Find nearest polyline with block</title>
      <link>https://forums.autodesk.com/t5/net-forum/find-nearest-polyline-with-block/m-p/3690822#M52630</link>
      <description>&lt;P&gt;You might be want instead to select block within the crossingpolygon method,&lt;/P&gt;&lt;P&gt;if you've added just one&amp;nbsp;block within, see if this helps:&lt;/P&gt;&lt;PRE&gt;        &amp;lt;CommandMethod("TUR")&amp;gt; _
        Public Shared Sub testUpdateRooms()
            Dim blockname As String = "ROOM"
            ' chnage block name
            Dim tagname As String = "ROOMAREA"
            ' change tag
            Dim db As Database = HostApplicationServices.WorkingDatabase
            Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
            Dim ed As Editor = doc.Editor

            Dim filtpline As TypedValue() = New TypedValue(1) {New TypedValue(0, "lwpolyline"), New TypedValue(70, 1)}
            Dim pres As PromptSelectionResult = ed.SelectAll(New SelectionFilter(filtpline))
            If pres.Status &amp;lt;&amp;gt; PromptStatus.OK Then
                Return
            End If
            Dim filtblock As TypedValue() = New TypedValue(1) {New TypedValue(0, "insert"), New TypedValue(2, blockname)}
            Using tr As Transaction = doc.TransactionManager.StartTransaction()
                For Each sobj As SelectedObject In pres.Value
                    Dim ent As DBObject = tr.GetObject(sobj.ObjectId, OpenMode.ForRead, False)
                    Dim pline As Polyline = TryCast(ent, Polyline)
                    If pline Is Nothing Then
                        Return
                    End If
                    Dim pts As New Point3dCollection()
                    For n As Integer = 0 To pline.NumberOfVertices - 2
                        pts.Add(pline.GetPoint3dAt(n))
                    Next
                    Dim res As PromptSelectionResult = ed.SelectCrossingPolygon(pts, New SelectionFilter(filtblock))

                    If res.Status &amp;lt;&amp;gt; PromptStatus.OK Then
                        Continue For
                    End If

                    Dim sset As SelectionSet = res.Value
                    If sset.Count = 0 Then
                        Continue For
                    End If
                    ' if more than one block found, then make polyline to be cyan colored to select room with extrafluous blocks
                    If sset.Count &amp;gt; 1 Then
                        pline.UpgradeOpen()
                        pline.ColorIndex = 121
                    Else
                        Dim ids As ObjectId() = sset.GetObjectIds()
                        Dim blkobj As DBObject = tr.GetObject(ids(0), OpenMode.ForRead, False)
                        Dim bref As BlockReference = TryCast(blkobj, BlockReference)
                        If bref Is Nothing Then
                            Continue For
                        End If
                        Dim atts As AttributeCollection = bref.AttributeCollection
                        For Each id As ObjectId In atts
                            Dim attref As AttributeReference = DirectCast(tr.GetObject(id, OpenMode.ForRead, False), AttributeReference)
                            If attref.Tag = tagname Then
                                bref.UpgradeOpen()
                                attref.UpgradeOpen()
                                attref.TextString = Math.Round(pline.Area, 2).ToString() '' i.e. precision 2 decimals, or
                                ' possible to use a field with pline area as well
                                attref.DowngradeOpen()
                                bref.DowngradeOpen()
                            End If
                        Next
                    End If
                Next
                tr.Commit()
            End Using
        End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2012 17:56:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/find-nearest-polyline-with-block/m-p/3690822#M52630</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-11-07T17:56:40Z</dc:date>
    </item>
    <item>
      <title>Re: Find nearest polyline with block</title>
      <link>https://forums.autodesk.com/t5/net-forum/find-nearest-polyline-with-block/m-p/3691694#M52631</link>
      <description>&lt;P&gt;Tnx, I'm going to try it!&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2012 08:07:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/find-nearest-polyline-with-block/m-p/3691694#M52631</guid>
      <dc:creator>wouter</dc:creator>
      <dc:date>2012-11-08T08:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Find nearest polyline with block</title>
      <link>https://forums.autodesk.com/t5/net-forum/find-nearest-polyline-with-block/m-p/3691848#M52632</link>
      <description>&lt;P&gt;It is a nice solution but it worked partly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First, I changed SelectCrossingPolygon to SelectWindowPolygon because some blocks are bigger dan the room, so they overlap with another room.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Secondly Some plines contain arcs, so the the returned vertices not always create a polygone that is around the block.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to also use of arcs in the pointselection to form the SelectWindowPolygon?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2012 10:58:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/find-nearest-polyline-with-block/m-p/3691848#M52632</guid>
      <dc:creator>wouter</dc:creator>
      <dc:date>2012-11-08T10:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Find nearest polyline with block</title>
      <link>https://forums.autodesk.com/t5/net-forum/find-nearest-polyline-with-block/m-p/3692040#M52633</link>
      <description>&lt;P&gt;I think in this case you an to gather the points along the polyline route&lt;/P&gt;&lt;P&gt;with small steps between,then&amp;nbsp;gather them all in the point3dcollection&lt;/P&gt;&lt;P&gt;to perform the &amp;nbsp;window selection&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2012 14:04:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/find-nearest-polyline-with-block/m-p/3692040#M52633</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-11-08T14:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Find nearest polyline with block</title>
      <link>https://forums.autodesk.com/t5/net-forum/find-nearest-polyline-with-block/m-p/3709990#M52634</link>
      <description>&lt;P&gt;tnx for your help!&lt;/P&gt;&lt;P&gt;Do you think it's possible to make a selection for just the insertion point of the block?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The size of the attributes changes with the different text lengths.&lt;BR /&gt;That makes it difficult to select just one block, because the text overlaps more then one pline...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Wouter&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2012 16:33:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/find-nearest-polyline-with-block/m-p/3709990#M52634</guid>
      <dc:creator>wouter</dc:creator>
      <dc:date>2012-11-23T16:33:56Z</dc:date>
    </item>
  </channel>
</rss>

