bim3d
2007-02-13, 04:39 PM
I'm using the following LISP code to define a command
(defun c:fix ()
(vl-vbarun "DeleteLayers")
)
It calls the following VBA routine:
Sub DeleteLayers()
Dim strLayers, strLayers1 As String
Dim objLayer As AcadLayer
' Initialize string.
strLayers = ""
strLayers1 = ""
' Step through all layers in the drawing.
For Each objLayer In ThisDrawing.Layers
If ((objLayer.Freeze) = True) Or (objLayer.LayerOn) = False Then
strLayers = objLayer.Name
strLayers1 = strLayers1 & objLayer.Name & vbCrLf
ThisDrawing.SendCommand "-laydel" & vbCr & "NAME" & vbCr & strLayers & vbCr & vbCr & "YES" & vbCr & vbCr
End If
Next
' Display the deleted layers to the user.
MsgBox "Layers deleted in current drawing: " & vbCrLf & vbCrLf & _
strLayers1
End Sub
This was running fine in AutoCAD 2007. But in AutoCAD 2005, the VBA routine keeps looping itself over and over again and won't return the command prompt. Any help or insights would be greatly appreciated.
(defun c:fix ()
(vl-vbarun "DeleteLayers")
)
It calls the following VBA routine:
Sub DeleteLayers()
Dim strLayers, strLayers1 As String
Dim objLayer As AcadLayer
' Initialize string.
strLayers = ""
strLayers1 = ""
' Step through all layers in the drawing.
For Each objLayer In ThisDrawing.Layers
If ((objLayer.Freeze) = True) Or (objLayer.LayerOn) = False Then
strLayers = objLayer.Name
strLayers1 = strLayers1 & objLayer.Name & vbCrLf
ThisDrawing.SendCommand "-laydel" & vbCr & "NAME" & vbCr & strLayers & vbCr & vbCr & "YES" & vbCr & vbCr
End If
Next
' Display the deleted layers to the user.
MsgBox "Layers deleted in current drawing: " & vbCrLf & vbCrLf & _
strLayers1
End Sub
This was running fine in AutoCAD 2007. But in AutoCAD 2005, the VBA routine keeps looping itself over and over again and won't return the command prompt. Any help or insights would be greatly appreciated.