Hello Everyone,
I was wondering if there was a macro that would delete all objects that are on an off layer. I haven't dabbled inVBA or lisp in a long time. I have AutoCAD 2007 so I mainly used VBA.
Any help is greatly appreciated.
Thanks,
Shawn
Hi Shawn,
here is a simple code..i haven't take into account whether the switched off layer is locked..hope it is usefu..
Sub DeleteFromSwitchedOffLayers()
Dim MyLayer As AcadLayer
Dim fType(0) As Integer
Dim fData(0) As Variant
Dim sset As AcadSelectionSet
On Error Resume Next
ThisDrawing.SelectionSets("sset0").Delete
On Error GoTo 0
Set sset = ThisDrawing.SelectionSets.Add("sset0")
fType(0) = 8 ' 8 - indicates that a layer is in selection
For Each MyLayer In ThisDrawing.Layers
If MyLayer.LayerOn = False Then
fData(0) = MyLayer.Name
sset.Select acSelectionSetAll, , , fType, fData
sset.Erase
ThisDrawing.Application.Update
End If
Next MyLayer
End Sub