Not applicable
07-07-2019
02:33 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have three subroutines in my macro (code below):
- myDraw to draw a line
- myOff to hide the line's layer
- myOn to show the line's layer
When I'm in AutoCAD and I call myDraw using -VBARUN, the line is drawn. When I then call myOff, I get a Lock Violation runtime error. When I click End on the popup, I can use myOff and myOn without problems. When I delete the line and re-call myDraw, I get the Lock Violation again.
The error does not occur when I run the subroutines from within the editor using "Run (F5)".
I am using AutoCAD 2020 on Windows 10
Code:
Public Sub myDraw() Dim pLine As AcadPolyline Dim LinePoints(0 To 5) As Double LinePoints(0) = -100 LinePoints(1) = 100 LinePoints(2) = 0 LinePoints(3) = 0 LinePoints(4) = 0 LinePoints(5) = 0 Set pLine = ThisDrawing.ModelSpace.AddPolyline(LinePoints) pLine.Layer = "0" End Sub Public Sub myOn() ThisDrawing.Layers("0").LayerOn = True End Sub Public Sub myOff() ThisDrawing.Layers("0").LayerOn = False End Sub
Solved! Go to Solution.
Link copied