Macro to toggle the sketch snapping in SOLIDWORKS document
This VBA macro allows to toggle on and off the 'Enable' option in SOLIDWORKS sketch.
Using macro in Toolbar+
This macro can be used in Toolbar+ which will improve the user experience. It is possible to enable the toggle state for the macro button.
Paste this code into the "Toggle Button State Code" text box:
Return CType(Application, Object).Sw.GetUserPreferenceToggle(249)
Download icon here
Dim swApp As SldWorks.SldWorks
Sub main()
Set swApp = Application.SldWorks
Dim curVal As Boolean
curVal = False <> swApp.GetUserPreferenceToggle(swUserPreferenceToggle_e.swSketchInference)
swApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swSketchInference, Not curVal
End Sub