VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Delete All Objects on an Off Layer

2 REPLIES 2
Reply
Message 1 of 3
XIJIANGWOO
645 Views, 2 Replies

How to Delete All Objects on an Off Layer

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

2 REPLIES 2
Message 2 of 3
sanganaksakha
in reply to: XIJIANGWOO

Selection set filters?

 

Message 3 of 3
vinayan
in reply to: XIJIANGWOO

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

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost