[ [CommandMethod("numberpoint")]
public void tpointt()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
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;
int num = 1;
TypedValue
[] tv
= new TypedValue
[1]; tv
.SetValue(new TypedValue
((int)DxfCode
.Start,
"point"),
0); SelectionFilter filter
= new SelectionFilter
(tv
); PromptSelectionResult ssPrompt;
ssPrompt = ed.GetSelection(filter);
if (ssPrompt.Status == PromptStatus.OK)
{
SelectionSet ss = ssPrompt.Value;
foreach (SelectedObject sObj in ss)
{
DBPoint spoint = trans.GetObject(sObj.ObjectId, OpenMode.ForWrite) as DBPoint;
DBText txt
= new DBText
(); txt.SetDatabaseDefaults();
txt.TextString = num.ToString();
txt
.Position = new Point3d
(spoint
.Position.X, spoint
.Position.Y, spoint
.Position.Z); txt.Rotation = 0;
txt.Height = 2;
btr.AppendEntity(txt);
trans.AddNewlyCreatedDBObject(txt, true);
num++;
}
trans.Commit();
}
}
}