acadDb.Database acadWorkingDB = acadDb.HostApplicationServices.WorkingDatabase;
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
acadDb.Transaction trans = acadWorkingDB.TransactionManager.StartTransaction();
try
{
acadDb.Circle circle = new acadDb.Circle(new acadGeom.Point3d(10, 10, 0), acadGeom.Vector3d.ZAxis, 2);
acadDb.BlockTable bt = (acadDb.BlockTable)trans.GetObject(acadWorkingDB.BlockTableId, acadDb.OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(
HostApplicationServices.WorkingDatabase.CurrentSpaceId,
OpenMode.ForWrite);
btr.AppendEntity(circle);
trans.AddNewlyCreatedDBObject(circle, true);
trans.Commit();
}
catch
{
ed.WriteMessage("Error ");
}
finally
{
trans.Dispose();
}
And finally one question: Why is there declaration of bt? It isn't further used... And when I comment it out with //, nothing happens, code works as it did before... At least it seems so.
It's sample from "AutoCAD 2007 .NET API Training Labs"