Community
Is there a property or method to do this?
If not is there a round-about way?
Hi ,
With below code you can find all vertices of a 2D polyline.
<CommandMethod("GV")> Public Sub GetVertice() Dim doc As Document = Application.DocumentManager.MdiActiveDocument Dim db As Database = doc.Database Dim ed As Editor = doc.Editor Dim peo As PromptEntityOptions = New PromptEntityOptions(vbLf & "Select a polyline:") Dim per As PromptEntityResult = ed.GetEntity(peo) If per.Status <> PromptStatus.OK Then Return End If Using tx As Transaction = db.TransactionManager.StartTransaction() Dim pl As Polyline = TryCast(tx.GetObject(per.ObjectId, OpenMode.ForRead), Polyline) For v = 0 To pl.NumberOfVertices - 1 MsgBox(pl.GetPoint2dAt(v).ToString) Next End Using End Sub
Hi,
If you're talking about (heavy) Polyline2d instance, you can use this extension method.
public static class Polyline2dExtensions { /// <summary> /// Gets the vertices list of the polyline 2d. /// </summary> /// <param name="pl">The instance to which the method applies.</param> /// <returns>The vertices list.</returns> /// <exception cref="Autodesk.AutoCAD.Runtime.Exception"> /// eNoActiveTransactions is thrown if the method is not called form a Transaction.</exception> public static List<Vertex2d> GetVertices(this Polyline2d pl) { Transaction tr = pl.Database.TransactionManager.TopTransaction; if (tr == null) throw new AcRx.Exception(AcRx.ErrorStatus.NoActiveTransactions); List<Vertex2d> vertices = new List<Vertex2d>(); foreach (ObjectId id in pl) { Vertex2d vx = (Vertex2d)tr.GetObject(id, OpenMode.ForRead); if (vx.VertexType != Vertex2dType.SplineControlVertex) vertices.Add(vx); } return vertices; } }
Can't find what you're looking for? Ask the community or share your knowledge.