Determine if Layer is Visible Example (VBA)
This example shows how to determine if a layer is visible.
'-----------------------------------------------
'
' Preconditions: Drawing document is open and has a layer
named Layer1.
'
' Postconditions: None
'
'-----------------------------------------------
Option Explicit
Sub main()
Dim
swApp As
SldWorks.SldWorks
Dim
swModel As
SldWorks.ModelDoc2
Dim
swDraw As
SldWorks.DrawingDoc
Dim
swLayerMgr As
SldWorks.LayerMgr
Dim
swLayer As
SldWorks.Layer
Set
swApp = Application.SldWorks
Set
swModel = swApp.ActiveDoc
Set
swLayerMgr = swModel.GetLayerManager
Set
swLayer = swLayerMgr.GetLayer("Layer1")
If
False = swLayer.Visible Then
swLayer.Visible = True
Else
swLayer.Visible = False
End
If
Debug.Print
swLayer.Visible
End Sub
'-----------------------------------------------