I have a routine in C # that lists all the vertices of a polyline. I wonder how the distance between each vertex and what angle to the y-axis of the drawing. Anyone have any ideas?


CODE:
Code:
[CommandMethod("listaVertices")]
        static public void ListVertices()
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;
            PromptEntityResult per = ed.GetEntity("Select a polyline");
            if (per.Status == PromptStatus.OK)
            {
                Transaction tr = db.TransactionManager.StartTransaction();
                using (tr)
                {
                    DBObject obj = tr.GetObject(per.ObjectId, OpenMode.ForRead);
                    // If a "lightweight" (or optimized) polyline
                    Polyline lwp = obj as Polyline;
                    if (lwp != null)
                    {
                        // Use a for loop to get each vertex, one by one
                        int vn = lwp.NumberOfVertices;
                        for (int i = 0; i < vn; i++)
                        {
                            // Could also get the 3D point here
                            Point2d pt = lwp.GetPoint2dAt(i);
                            ed.WriteMessage("\n" + pt.ToString());
                        }
                    }
                    else
                    {
                        // If an old-style, 2D polyline
                        Polyline2d p2d = obj as Polyline2d;
                        if (p2d != null)
                        {
                            // Use foreach to get each contained vertex
                            foreach (ObjectId vId in p2d)
                            {
                                Vertex2d v2d = (Vertex2d)tr.GetObject(vId, OpenMode.ForRead);
                                ed.WriteMessage("\n" + v2d.Position.ToString());
                            }
                        }
                        else
                        {
                            // If an old-style, 3D polyline
                            Polyline3d p3d = obj as Polyline3d;
                            if (p3d != null)
                            {
                                // Use foreach to get each contained vertex
                                foreach (ObjectId vId in p3d)
                                {
                                    PolylineVertex3d v3d = (PolylineVertex3d)tr.GetObject(vId, OpenMode.ForRead);
                                    ed.WriteMessage("\n" + v3d.Position.ToString());
                                }
                            }
                        }
                    }
                    // Committing is cheaper than aborting
                    tr.Commit();
                }
            }
        }
Thanks!
Rodrigo