MACRO LIBRARY

Debug.assert example

Free public access. No account or subscription required.

Files

Debug.assert example

Code

'Debug:Assert conditionally suspends execution at the line on _
which the method appears.
    
'In this case, if the document is not a part then retval will be true.
'If retval is true then debug.assert pauses execution.
    
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
Option Explicit
    
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim retval As Boolean
    
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    
    If swModel.GetType <> swDocPART Then retval = True
    Debug.Assert retval
    
    
    swApp.SendMsgToUser2 "This is not a part document!", swMbWarning, swMbOk
End Sub