Тема: Возникает ошибка при работе программы
Есть одна форма и на ней кнопка.
При нажатии кнопки должна чертится линия, но возникает ошибка в Автокаде:
"Необрабатываемое исключение в компоненте приложения. eLockViolation"
Код находится внутри формы (по привычке взятой из VBA).
Код:
Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.EditorInput Imports Autodesk.AutoCAD.Geometry Imports Autodesk.AutoCAD.Runtime Public Class UserForm2 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Hide() '' Get the current database and start the Transaction Manager Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument Dim acCurDb As Database = acDoc.Database Dim pPtRes As PromptPointResult Dim pPtOpts As PromptPointOptions = New PromptPointOptions("") '' Prompt for the start point pPtOpts.Message = vbLf & "Enter the start point of the line: " pPtRes = acDoc.Editor.GetPoint(pPtOpts) Dim ptStart As Point3d = pPtRes.Value '' Exit if the user presses ESC or cancels the command If pPtRes.Status = PromptStatus.Cancel Then Exit Sub '' Prompt for the end point pPtOpts.Message = vbLf & "Enter the end point of the line: " pPtOpts.UseBasePoint = True pPtOpts.BasePoint = ptStart pPtRes = acDoc.Editor.GetPoint(pPtOpts) Dim ptEnd As Point3d = pPtRes.Value If pPtRes.Status = PromptStatus.Cancel Then Exit Sub '' Start a transaction Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction() Dim acBlkTbl As BlockTable Dim acBlkTblRec As BlockTableRecord '' Open Model space for write acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, _ OpenMode.ForRead) acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _ OpenMode.ForWrite) '' Define the new line Dim acLine As Line = New Line(ptStart, ptEnd) acLine.SetDatabaseDefaults() '' Add the line to the drawing acBlkTblRec.AppendEntity(acLine) acTrans.AddNewlyCreatedDBObject(acLine, True) '' Zoom to the extents or limits of the drawing acDoc.SendStringToExecute("._zoom _all ", True, False, False) '' Commit the changes and dispose of the transaction acTrans.Commit() End Using End Sub End Class
В чем ошибка подскажите пожалуйста???