Preview | SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
NTNick Tzallas02/07/2020
****added code of macro used***
I recently found this older forum post and was hoping to use the macro to delete layers on some old legacy drawings we have here.
Running the macro on the open drawing, it does work, almost.
It deletes all layers except the first one in the list.
Am I not seeing something obvious here?
or is it it maybe an old macro version clashing with SW version?
Any insight would be appreciated
Please see below the macro I am using
Sub main()
Dim swApp As SldWorks.SldWorks
Dim doc As ModelDoc2
Dim lyrMgr As LayerMgr
Dim v As Variant
Dim i As Integer
Dim count As Integer
Set swApp = Application.SldWorks
Set doc = swApp.ActiveDoc
Set lyrMgr = doc.GetLayerManager
count = lyrMgr.GetCount
v = lyrMgr.GetLayerList
For i = 1 To count - 1
lyrMgr.DeleteLayer (v(i))
Next i
End Sub
See below screenshots for before and after macro
Running SW 2020 SP 3.0
Templates, sheet formats, drafting standards etc, have been created fresh in SW 2020
Win 10 Pro 64-bit (2004 Build)