in this code, I write it to make auto number but numbers do not draw after click when pressing ESC all number draw. I want to write each number after a click
[CommandMethod("autonumber")]
public void writecoorpoint()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
PromptPointOptions ppoint1;
PromptPointResult pr1;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord btr = trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
PromptIntegerOptions pintop = new PromptIntegerOptions("\nenter start number");
PromptIntegerResult pinreslet = ed.GetInteger(pintop);
int num = pinreslet.Value;
while (true)
{
ppoint1 = new PromptPointOptions("\nspecifay point :");
pr1 = ed.GetPoint(ppoint1);
if (pr1.Status == PromptStatus.Cancel)
{
break;
}
else if (pr1.Status == PromptStatus.OK)
{
MText mt1 = new MText();
mt1.SetDatabaseDefaults();
mt1.Location = pr1.Value;
mt1.Contents = num.ToString();
mt1.TextHeight = .5;
btr.AppendEntity(mt1);
trans.AddNewlyCreatedDBObject(mt1, true);
DBPoint point = new DBPoint(pr1.Value);
btr.AppendEntity(point);
trans.AddNewlyCreatedDBObject(point, true);
num = num + 1;
}
}
trans.Commit();
}
}
}
}