Code:
// Erzeuge Polyrechteck
Polyline acLine = new Polyline();
acLine.SetDatabaseDefaults();
acLine.AddVertexAt(0, new Point2d(ptStart.X + V0, ptStart.Y + V0), 0, 0, 0);
acLine.AddVertexAt(1, new Point2d(ptStart.X + V1, ptStart.Y + V0), 0, 0, 0);
acLine.AddVertexAt(2, new Point2d(ptStart.X + V1, ptStart.Y + V1), 0, 0, 0);
acLine.AddVertexAt(3, new Point2d(ptStart.X + V0, ptStart.Y + V1), 0, 0, 0);
acLine.AddVertexAt(4, new Point2d(ptStart.X + V0, ptStart.Y + V0), 0, 0, 0);
// Add the line to the drawing
acBlkTblRec.AppendEntity(acLine);
acTrans.AddNewlyCreatedDBObject(acLine, true);
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
PromptEntityOptions opt = ed.SelectLast();
PromptEntityResult res = ed.GetEntity(opt);
if (res.Status == PromptStatus.OK)
{
Transaction tr = doc.TransactionManager.StartTransaction();
using (tr)
{
DBObject obj = tr.GetObject(res.ObjectId, OpenMode.ForWrite);