我想在绘图区域上显示实体作为用户的预览,然后如果用户接受程序,将实体添加到数据库或进行一些修改。
我习惯于使用事务并提交实体出现的事务,如果我可以让实体在提交事务之前出现
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
int i = poly2TxtSetting.currentFormat.IndexFormat.startWith;
List<ObjectId> ListTextId = new List<ObjectId>();
List<ObjectId> ListPointId = new List<ObjectId>();
foreach (var po in Points)
{
i += poly2TxtSetting.currentFormat.IndexFormat.step;
DBText dtext = new DBText();
dtext.TextString = i.tostring();
dtext.Position = po;
dtext.SetDatabaseDefaults();
DBPoint point = new DBPoint(po);
btr.AppendEntity(dtext);
tr.AddNewlyCreatedDBObject(dtext, true);
btr.AppendEntity(point);
tr.AddNewlyCreatedDBObject(point, true);
}
tr.Commit();
}