quick background: I'm trying to write a macro that inserts a sketch, asks the user to select a face or other sketch to conver it's entities, creates a revolve cut of this, then asks the user to select component(s) for the feature scope of the revolve cut. I've got this all working except the two spots that require the user to make selection(s). As below, I've got it working if I start the sub from the VB editor, but not from Mouse Gestures or Toolbar buttons. SO.......
I know it's been asked before and answered a million and one times but I've not figured this one out!!!!
I've done everything from the YesBox here: https://forum.solidworks.com/message/88280#88280
to "sleep 5000" and DoEvents loops etc.
the simplest example of what happens is if you run this by pressing the play button in the VB Editor it works, but if you launch it from a toolbar button mapped to it you can't select something and the loop fails. If you select a bunch of times you can actually watch all your selections play back quickly AFTER the sub fails.
Sub NeedInputStephanie()
Dim swApp As SldWorks.SldWorks
Dim SelMgr As SldWorks.SelectionMgr
Dim swDoc As SldWorks.ModelDoc2
Dim failSafe As Integer
Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
Set swSelMgr = swDoc.SelectionManager
failSafe = 1
swDoc.ClearSelection2 True 'Clear all selections
While swSelMgr.GetSelectedObjectCount < 1
DoEvents 'Wait for user selection
failSafe = failSafe + 1
If failSafe = 1000 Then
MsgBox "FAILURE!"
Exit Sub
End If
Wend
MsgBox "Tell them what they've won Johnny"
End Sub