Pls help. I have a function under a form class and i am getting an elockviolation error everytime i execute the function. Does anyone know why this occurs?
Private Sub createP1()
Dim myTransMan As DatabaseServices.TransactionManager
Dim myTrans As DatabaseServices.Transaction
Dim myDwg As Document
Dim myBT As BlockTable
Dim myBTR As BlockTableRecord
Dim startPt As Geometry.Point3d
Dim endPt As Geometry.Point3d
Dim myBTE As SymbolTableEnumerator
myDwg = Application.DocumentManager.MdiActiveDocument
myTransMan = myDwg.TransactionManager
myTrans = myTransMan.StartTransaction
myBT = myDwg.Database.BlockTableId.GetObject(OpenMode.ForWrite) <------ here is where the error is (elockviolation)
Dim i As Integer = 0
Dim bfound As Boolean = False
myBTE = myBT.GetEnumerator
While (myBTE.MoveNext = True) And (Not bfound)
myBTR = myBTE.Current.GetObject(OpenMode.ForRead)
If myBTR.Name = "LineBlock" Then bfound = True
End While
If Not bfound Then
startPt = New Geometry.Point3d(0, 0, 0)
endPt = New Geometry.Point3d(2, 3, 0)
Dim line1 As New Line(startPt, endPt)
myBTR = New BlockTableRecord
myBTR.Name = "LineBlock"
myBTR.AppendEntity(line1)
myBT.Add(myBTR)
myTrans.AddNewlyCreatedDBObject(myBTR, True)
End If
myTrans.Commit()
myTrans.Dispose()
myTransMan.Dispose()
End Sub
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"a7v1n" wrote in message
href="news:6085484@discussion.autodesk.com">news:6085484@discussion.autodesk.com...
Pls help. I have a function under a form class and i am getting
an elockviolation error everytime i execute the function. Does anyone know why
this occurs?
Private Sub createP1()
Dim
myTransMan As DatabaseServices.TransactionManager
Dim myTrans As
DatabaseServices.Transaction
Dim myDwg As Document
Dim myBT As
BlockTable
Dim myBTR As BlockTableRecord
Dim startPt As
Geometry.Point3d
Dim endPt As Geometry.Point3d
Dim myBTE As
SymbolTableEnumerator
myDwg =
Application.DocumentManager.MdiActiveDocument
myTransMan =
myDwg.TransactionManager
myTrans =
myTransMan.StartTransaction
myBT =
myDwg.Database.BlockTableId.GetObject(OpenMode.ForWrite) <------ here is
where the error is (elockviolation)
Dim i As Integer = 0
Dim
bfound As Boolean = False
myBTE = myBT.GetEnumerator
While
(myBTE.MoveNext = True) And (Not bfound)
myBTR =
myBTE.Current.GetObject(OpenMode.ForRead)
If myBTR.Name = "LineBlock"
Then bfound = True
End While
If Not bfound Then
startPt =
New Geometry.Point3d(0, 0, 0)
endPt = New Geometry.Point3d(2, 3,
0)
Dim line1 As New Line(startPt, endPt)
myBTR = New
BlockTableRecord
myBTR.Name =
"LineBlock"
myBTR.AppendEntity(line1)
myBT.Add(myBTR)
myTrans.AddNewlyCreatedDBObject(myBTR,
True)
End
If
myTrans.Commit()
myTrans.Dispose()
myTransMan.Dispose()
End
Sub
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"a7v1n" wrote in messagehi.
href="news:6087293@discussion.autodesk.com">news:6087293@discussion.autodesk.com...
do i need to unlock the document after i lock it? if yes, how do you unlock a
document?
Hi. Is this coding correct? This is done in vb.net and I'm not sure if the drawing is unlocked after the command finished executing. Thanks so much.
Dim lock As DocumentLock
myDwg = Application.DocumentManager.MdiActiveDocument
lock = myDwg.LockDocument
Using lock
....
End Using