hello,everybody!
I get a error 'eWasOpenForWrite' in the code below, can anyone tell me how to tackle this problem?
thanks.
Code:
private static void CheckInference(List<Solid3d> solids) {
Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;
using (Transaction tran = db.TransactionManager.StartTransaction()) {
BlockTable blockTable = tran.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord blockRecord = tran.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
for (int i = 0; i < solids.Count - 1; i++) {
Solid3d solid1 = solids[i];
for (int j = i + 1; j < solids.Count; j++) {
Solid3d solid2 = solids[j];
if (solid1.Layer != solid2.Layer) {
if (solid1.CheckInterference(solid2)) {
Solid3d copySolid1 = solid1.Clone() as Solid3d;
copySolid1 .BooleanOperation(BooleanOperationType.BoolIntersect, solid2.Clone() as Solid3d);//------eWasOpenForWrite error occured here
copySolid1 .ColorIndex = 1;
blockRecord.AppendEntity(copySolid1 );
tran.AddNewlyCreatedDBObject(copySolid1 , true);
tran.Commit();
}
}
}
}
}
}