[CommandMethod("MyGroup", "MyPoly", "MyPolyLocal", CommandFlags.Modal)]
public void MyPoly()
{
Database db = Application.DocumentManager.MdiActiveDocument.Database;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
using (Transaction ts = db.TransactionManager.StartTransaction())
{
BlockTableRecord btr = (BlockTableRecord)ts.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
List<Polyline> pls = new List<Polyline>();
Polyline polyline = new Polyline();
polyline.AddVertexAt(0, new Point2d(0.0, 0.0), 0.0, 0.0, 0.0);
polyline.AddVertexAt(0, new Point2d(1.0, 0.0), 0.0, 0.0, 0.0);
Polyline polyline1 = new Polyline();
polyline1.AddVertexAt(0, new Point2d(3.0, 2.0), 0.0, 0.0, 0.0);
polyline1.AddVertexAt(0, new Point2d(2.0, 1.0), 0.0, 0.0, 0.0);
polyline1.AddVertexAt(0, new Point2d(1.5, 0.0), 0.0, 0.0, 0.0);
//polyline1.AddVertexAt(0, new Point2d(1.0, 0.0), 0.0, 0.0, 0.0);
pls.Add(polyline1);
try
{ polyline.JoinEntities(pls.ToArray()); }
catch(Autodesk.AutoCAD.Runtime.Exception e) { ed.WriteMessage("\nExcaption message: " + e.Message); }
btr.AppendEntity(polyline);
ts.AddNewlyCreatedDBObject(polyline, true);
ts.Commit();
}
}