Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Can someone please try to spot what's wrong to get an eWasOpenForWrite on the line
db.Clayer = acLyrTbl("DIM")
Private Sub doc_CommandWillStart(ByVal sender As Object, ByVal e As CommandEventArgs) If PauseEvents = False Then If e.GlobalCommandName = "DIMLINEAR" Or e.GlobalCommandName = "DIMALIGNED" Or e.GlobalCommandName = "DIMANGULAR" Or e.GlobalCommandName = "DIMCONTINUE" Then Using trans As Transaction = Application.DocumentManager.MdiActiveDocument.TransactionManager.StartOpenCloseTransaction : trcnt = trcnt + 1 Dim LayerName As String = "DIM" Dim lyrId As ObjectId = Nothing Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database Try Dim lyrTbl As LayerTable = trans.GetObject(db.LayerTableId, OpenMode.ForRead, False) Using ltypTbl As LinetypeTable = trans.GetObject(db.LinetypeTableId, OpenMode.ForRead, False) Using myLayer As LayerTableRecord = New LayerTableRecord If lyrTbl.Has(LayerName) = False Then myLayer.Name = LayerName lyrTbl.UpgradeOpen() lyrTbl.Add(myLayer) trans.AddNewlyCreatedDBObject(myLayer, True) End If lyrId = lyrTbl.Item(LayerName) End Using End Using Dim acLyrTbl As LayerTable = trans.GetObject(db.LayerTableId, OpenMode.ForRead) If acLyrTbl.Has("DIM") = True Then db.Clayer = acLyrTbl("DIM") End If trans.Commit() Catch ex As Exception MsgBox(Reflection.MethodBase.GetCurrentMethod.Name() + " Exception: " + ex.Message) End Try End Using End If End If End Sub
Solved! Go to Solution.