How to use API to identify if user is currently editing a sketch?

I feel like this should be a simple question but its baffled me all afternoon. I want to check to see if a sketch is currently being edited so I can prevent a macro from running if this is the case.  How would I find this out?

SolidworksApi/macros
Answers 2
JB
JB 2021-04-08 Best Answer

Sub main()

Dim swSketch As SldWorks.Sketch
Set swSketch = Application.SldWorks.ActiveDoc.SketchManager.ActiveSketch
If swSketch Is Nothing Then
MsgBox "No sketch active"
Else
MsgBox "Active sketch: " & swSketch.Name
End If
End Sub

DM
DM 2021-04-08

Perfect, thank you.  "if Var is Nothing" is exactly what I never knew I needed.