first of all, thanks to Josh Brady and Jacob Cordingley who tried to help me whit this
this is the latest attempt, visual basic doesn't find anything wrong but the macro isn't doing a thing on my drawings.
I put some test sheets and if somebody can fix my macro (solidworks 2007) I'd be real happy
as a reminder, want I want to do is to meke a layer (PROTO) visible/invisible to all opened drawing files in solidworks.
I do have a macro that do it for active file and I'm sure we can do it for the opened ones.
thanks a lot....
Dim swApp As Object
'------------------------------------
' Preconditions:
' (1) Drawing document is open.
' (2) Drawing document contains a layer named PROTO.
'
' Postconditions:
' If PROTO layer is visible, then it becomes not visible.
' - or -
' If PROTO layer is not visible, then it becomes visible.
'
'------------------------------------------------------------------
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swLayerMgr As SldWorks.LayerMgr
Dim swLayer As SldWorks.Layer
Set swApp = Application.SldWorks
Set swModel = swApp.GetFirstDocument
While Not swModel Is Nothing
' check if file is drawing
If (swModel.GetType = swDocumentTypes_e.swDocDRAWING) Then
Set swLayerMgr = swModel.GetLayerManager
Set swLayer = swLayerMgr.GetLayer("PROTO")
If swLayer.Visible = False Then
' Toggle layer on
swLayer.Visible = True
Debug.Assert True = swLayer.Visible
Else
' Toggle layer off
swLayer.Visible = False
Debug.Assert False = swLayer.Visible
End If
End If
Set swModel = swModel.GetNext
Wend
End Sub