.NET

Reply
Contributor
supec
Posts: 19
Registered: ‎11-01-2006
Message 1 of 1 (50 Views)

bt and btr

50 Views, 0 Replies
11-01-2006 11:30 AM
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"
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.