- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So I seem to be having some issues with using VB.net. I looked at the helloWorld sample, as well as the makeEnts sample and I can't seem to resolve the fack that I get a eLockViolation error that pops up and mentioned JIT issues. So what I was trying to do is simple run a routine to load a forum which allows the user to select which new layers to create. That being said the code I use to create the layers within the forum fails every time. If I move the code to create the layers into the main file shopSetup.vb instead of shopSetupForm.vb then it work. I know that it isn't a problem with the code specfically but maybe that the form doesn't have access to the currently open document or something? I am not sure really and I am just kind of guessing. Please let me know thank you.
***********************************************************
shopSetup.vb
***********************************************************
Option Explicit On
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports DBTransMan = Autodesk.AutoCAD.DatabaseServices.TransactionManager
Namespace shopSetup
Public Class shopSetup
<Autodesk.AutoCAD.Runtime.CommandMethod("Setup")> _
Public Sub setupCommand()
Dim userForm As New shopSetupForm()
Application.ShowModelessDialog(userForm)
End Sub
End Class
End Namespace
***********************************************************
shopSetup.vb
***********************************************************
Option Explicit On
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports DBTransMan = Autodesk.AutoCAD.DatabaseServices.TransactionManager
Public Class shopSetupForm
Private Sub okButton_Click(sender As System.Object, e As System.EventArgs) Handles okButton.Click
Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
Dim tm As DBTransMan = db.TransactionManager
Dim ta As Transaction = tm.StartTransaction()
Try
Dim LT As LayerTable = tm.GetObject(db.LayerTableId, OpenMode.ForRead, False)
If LT.Has("ASDK_MYLAYER") = False Then
Dim LTRec As New LayerTableRecord()
LTRec.Name = "ASDK_MYLAYER"
LT.UpgradeOpen()
LT.Add(LTRec)
tm.AddNewlyCreatedDBObject(LTRec, True)
ta.Commit()
End If
Finally
ta.Dispose()
End Try
'Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
'Dim tm As DBTransMan = db.TransactionManager
'Dim ta As Transaction = tm.StartTransaction()
'If slabCheckBox.Checked = True Then
' Dim LT As LayerTable = tm.GetObject(db.LayerTableId, OpenMode.ForRead, False)
' Dim layers As New List(Of String) From {"SLAB-EDGE", "SLAB-GRID", "SLAB-MISC", "SLAB-DEFPOITNS"}
' Try
' For Each layerName In layers
' If LT.Has(layerName) = False Then
' Dim LTRec As New LayerTableRecord
' LTRec.Name = layerName
' LT.UpgradeOpen()
' LT.Add(LTRec)
' tm.AddNewlyCreatedDBObject(LTRec, True)
' ta.Commit()
' End If
' Next
' Finally
' ta.Dispose()
' End Try
'End If
'Me.Close()
End Sub
Private Sub quitButton_Click(sender As System.Object, e As System.EventArgs) Handles quitButton.Click, quitButton.Click
Me.Close()
End Sub
End ClassI have inclued both the code for simple review and also the entire vb directory for further review. Thank you in advance for your help. This is my first .net application so I am still learning a bit, I do like the .net format more then the C++ format due to the decrease in complexity of the pointers, as well as all the issues I was having with setting up a project etc.
Solved! Go to Solution.