public void TestPoint2dGroup() { var doc = Application.DocumentManager.MdiActiveDocument; var db = doc.Database; var ed = doc.Editor; var selRes = ed.GetEntity("Выбери полилинию"); if (selRes.Status != PromptStatus.OK) { return; } using (var t = db.TransactionManager.StartTransaction()) { var pl = selRes.ObjectId.GetObject(OpenMode.ForWrite) as Polyline; if (pl == null) { return; } var pts = pl.GetPoints(); var comparer = new AcadLib.Comparers.Point2dEqualityComparer(5); var group = pts.GroupBy(g => g, comparer).Select(s => s.Key).ToList(); var newPl = group.CreatePolyline(); var cs = db.CurrentSpaceId.GetObject(OpenMode.ForWrite) as BlockTableRecord; cs.AppendEntity(newPl); t.AddNewlyCreatedDBObject(newPl, true); pl.Erase(); t.Commit(); } }
public void TestPoint2dGroup() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; var selRes = ed.GetEntity("Выбери полилинию"); if (selRes.Status != PromptStatus.OK) return; using (var t = db.TransactionManager.StartTransaction()) { var pl = selRes.ObjectId.GetObject(OpenMode.ForWrite) as Polyline; if (pl == null) return; var pts = pl.GetPoints(); var comparer = new AcadLib.Comparers.Point2dEqualityComparer(5); var group = pts.GroupBy(g => g, comparer).Select(s=>s.Key).ToList(); var newPl = group.CreatePolyline(); var cs = db.CurrentSpaceId.GetObject(OpenMode.ForWrite) as BlockTableRecord; cs.AppendEntity(newPl); t.AddNewlyCreatedDBObject(newPl, true); pl.Erase(); t.Commit(); } }