[CommandMethod("tt6")] public static void test26() {
Document doc = Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; Database db = doc.Database;
var resSel = ed.SelectAll( new ResultList { { 0, "point,lwpolyline" } });
List<oint3d> pts = new List<oint3d>(); List<oint3d> nodes = new List<oint3d>();
using (var tr = db.TransactionManager.StartTransaction()) { foreach (ObjectId id in resSel.Value.GetObjectIds()) { Entity ent = tr.GetObject(id, OpenMode.ForRead) as Entity; if (ent is DBPoint) { pts.Add(((DBPoint)ent).Position); } else { Polyline pl = ent as Polyline; for (int i = 0; i < pl.NumberOfVertices; i++) { nodes.Add(pl.GetPoint3dAt(i)); } } }
foreach (Point3d pt in pts) { Point3d res = nodes.FindByMinKey(p => p.DistanceTo(pt)); ed.DrawPoint(res.Convert2d(new Plane()), 2, res.DistanceTo(pt), 8); }
} }
|