AnsweredAssumed Answered

Trying to turn off layer in drawing through pdm task

Question asked by Ben Sampson on Jun 13, 2019

I have a simple macro that runs fine in Solidworks to hide a layer in a drawing, but when I try to run it as a task in PDM Professional 2019 it errors out. Can someone tell me what I'm doing wrong here? It stops running at Set swLayerMgr = swModel.GetLayerManager as swLayerMgr = Nothing...Don't know why it isn't passing the value.



Dim swApp As Object
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.ActiveDoc

Set swLayerMgr = swModel.GetLayerManager

Set swLayer = swLayerMgr.GetLayer("PRELIMINARY")

swLayer.Visible = False

Debug.Assert False = swLayer.Visible

End Sub