Why would I get an error that says eLockViolation on the line "BlockTable bt = (BlockTable)thisDB.BlockTableId.GetObject(OpenMode.ForWrite);"
???
----------------------
private void StampDrawing(string fullDwgPath, string stampString, bool FullSize)
{
Document ThisDrawing = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(fullDwgPath);
Database thisDB = ThisDrawing.Database;
Autodesk.AutoCAD.ApplicationServices.TransactionManager tm = ThisDrawing.TransactionManager;
using (Transaction trans = tm.StartTransaction())
{
BlockTable bt = (BlockTable)thisDB.BlockTableId.GetObject(OpenMode.ForWrite);
BlockTableRecord modelsp = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
DBText stampText = new DBText();
stampText.TextString = stampString;
stampText.Height = 12;
stampText.HorizontalMode = TextHorizontalMode.TextRight;
stampText.Rotation = 0;
modelsp.AppendEntity(stampText);
trans.TransactionManager.AddNewlyCreatedDBObject(stampText, true);
trans.Commit();
}
tm.Dispose();
ThisDrawing.CloseAndSave(fullDwgPath);
thisDB.Dispose();
}
----------------------
The file opens fine but I am unable to get the blocktable.
CAD Programming Solutions