- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Using AutoCAD 2019 and VBA...
I have a situation where I want to delete unneeded layers. I have created a list box where the layers can be selected and then I'm using SendCommand to run the "-laydel" command.
Dim Selection As String
Dim strDelete As String
For i = 0 To lbxExistLayers.ListCount - 1 'Each Selection In lbxExistLayers
If lbxExistLayers.Selected(i) = True Then
Selection = Selection & lbxExistLayers.List(i) & vbCrLf
strDelete = strDelete & "Name" & vbCr & lbxExistLayers.List(i) & vbCr
End If
Next i
Result = MsgBox("The following layer(s) AND ANY OBJECTS on them will be deleted from the drawings." & vbCrLf & vbCrLf & Selection & vbCrLf & "Are you sure you want to delete the layer(s)?", vbYesNoCancel + vbExclamation, "Warning!")
If Result = vbYes Then
ThisDrawing.SendCommand "-laydel" & vbCr & "Name" & vbCr & strDelete & vbCr & "Y" & vbCr
End If
The problem is that after the SendCommand has executed, AutoCAD , VBA, and the VBA form are "frozen". I have to use the task manage to end the AutoCAD process. However, if I put a break point on the line SendCommand line in the VBA subroutine, execution halts at that line as it should for debugging, and i can step through using the F8 key with out any issues. The send command completes and the subroutine ends as it should without "freezing". But if I put the break point on the line after SendCommand, the "End If" line, the "freeze" will occur.
Any help is appreciated.
Solved! Go to Solution.