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

Return the coordinates of a LWPOLYLINE

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
gablackburn
655 Views, 3 Replies

Return the coordinates of a LWPOLYLINE

I realize this is probably a VB.NET 101 question, but it's been a couple days and I'm getting frustrated.

 

I want to get a collection of the Point3D values (coordinates) of a LWPOLYLINE (open or closed), that's it. For example, while in AutoCAD, if I use the LIST command on my polyline, I get the following results;

 

 

at point X= 100'-0" Y= 100'-0" Z= 0'-0"
at point X= 110'-0" Y= 100'-0" Z= 0'-0"
at point X= 110'-0" Y= 105'-0" Z= 0'-0"
at point X= 105'-0" Y= 105'-0" Z= 0'-0"
at point X= 105'-0" Y= 110'-0" Z= 0'-0"
at point X= 100'-0" Y= 110'-0" Z= 0'-0"

 

I need my sub to give me the coordinates shown above, but cannot find a way to do it. I'm aware of Polyline.GeometryExtents and Polyline.Bounds, but all that does is give me the coordinates of the opposite corners, and doesn't account for the fact a rectangle may be rotated.

 

Any help is very appreciated.

 

Thanks in advance,

George

3 REPLIES 3
Message 2 of 4
norman.yuan
in reply to: gablackburn

Look at Polyline.NumberOfVertices property and Polyline.GetPoint3dAt() method.

 

Assume you have already obtained a valid Polyline object, represented with variable "pline":

 

Dim pts As New List(of Point3d)()

For i As Integer=0 To pline.NumberOfVertices

 pts.Add(pline.GetPoint3dAt(i)

Next

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 4

For I as Integer = 0 to pline.NumberOfVertices - 1

Details are tiny daggers 😉

Dave O.                                                                  Sig-Logos32.png
Message 4 of 4
gablackburn
in reply to: norman.yuan

Thank you so much norman.yuan & cheifbraincloud, was exactly what I needed.I clicked both responses as the 'accepted solution'.

 

I thought it would be something simple, and of course, it was, I just couldn't find the solution here or at theswamp.org.

 

George

 

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