.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Read vertices of a polyline

4 REPLIES 4
Reply
Message 1 of 5
matejt
9405 Views, 4 Replies

Read vertices of a polyline

Hi,

I need to read all vertices of a polyline and extract coordinates.

Could you please tell me how to do that in VB.NET?

Thanx,

4 REPLIES 4
Message 2 of 5
asim777
in reply to: matejt

 

VB.Net code -  
 Public Shared Function getAllVertices(ByVal ent As Polyline) As Point2dCollection
        Dim verCollection As Point2dCollection = New Point2dCollection()
        Dim vertex As Point2d
        Dim i As Integer = 0
        For i = 0 To ent.NumberOfVertices - 1
            vertex = ent.GetPoint2dAt(i)
            verCollection.Add(vertex)
        Next
        Return verCollection
    End Function

    Public Shared Function getAllVertices(ByVal ent As Polyline) As Point2dCollection        Dim verCollection As Point2dCollection = New Point2dCollection()        Dim vertex As Point2d        Dim i As Integer = 0        For i = 0 To ent.NumberOfVertices - 1            vertex = ent.GetPoint2dAt(i)            verCollection.Add(vertex)        Next        Return verCollection    End Function

 

Message 3 of 5
matejt
in reply to: asim777

Thank you for the response.

In fact, I need to read vertices of 3D Polylines and have problems finding NumberOfVertices property...

Could you suggest me in this regard? Thanx,

Message 4 of 5
chiefbraincloud
in reply to: matejt

Depending on circumstances, in the past I have used Polyline3d.GetStretchPoints.  You pass it an empty Point3dCollection and it fills the collection.

 

That said, it doesn't work when the polyline is not db resident, and I'm not sure what it would do if the Polyline was not type SimplePoly, so, this is another way.

 

For I as Integer = 0 to Poly3d.EndParam

      PointCol.Add (Poly3d.GetPointAtParameter(I))

Next I 

 

 

Dave O.                                                                  Sig-Logos32.png
Message 5 of 5
matejt
in reply to: matejt

This is a way to do it:

 

Sub Read3DPolyline(ByVal poly3d As Polyline3d)
        '' Start a transaction
        Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()

            Dim vId As ObjectId
            For Each vId In poly3d
                Dim v3d As PolylineVertex3d = acTrans.GetObject(vId, OpenMode.ForRead)
                acDoc.Editor.WriteMessage(vbCrLf + v3d.Position.ToString())
            Next
            acTrans.Commit()
        End Using
    End Sub

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost