Message 1 of 5
Lock violation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a project which causes a run-time error '-2145386306 (802000be)'
I reduced the code causing the error to the following:
Events in ThisDrawing module:
Public entObj As Object
Sub AcadDocument_ObjectAdded(ByVal Object As Object)
If Object.ObjectName = "AcDbPolyline" Then Set entObj = Object
End Sub
Sub AcadDocument_EndCommand(ByVal CommandName As String)
If CommandName = "COPY" Then
Dim explodedObjects As Variant
Dim DataType(1) As Integer, Data(1) As Variant
DataType(0) = 1001: Data(0) = "Test_Application"
DataType(1) = 1000: Data(1) = "This is a test for xdata"
entObj.SetXData DataType, Data
explodedObjects = entObj.Explode
End If
End Sub
Procedure in a regular module:
Sub lockViolation()
Dim i As Integer
Dim entObj2 As AcadEntity
Dim DataType(1) As Integer, Data(1) As Variant
DataType(0) = 1001: Data(0) = "Test_Application"
DataType(1) = 1000: Data(1) = "This is a test for xdata"
For i = 0 To ThisDrawing.ModelSpace.Count - 1
Set entObj2 = ThisDrawing.ModelSpace.Item(i)
If entObj2.ObjectName = "AcDbPolyline" Then entObj2.SetXData DataType, Data
Next i
End Sub
I attached a drawing with a single polyline. The error occurs if after copying the polyline twice (the copy mode must be set to "single") I run the "lockViolation" procedure. The error pops in: "entObj2.SetXData DataType, Data", even if entObj2 isn't one of the exploded polylines.
What should I do to prevent this lock violation error?
Thanks in advance.