Quite by accident, I happened to meet someone who had developed portions of the
API. I asked him to look over the code. He and I spent several hours on it and
he recognized that there is a problem running this out of process but couldn't
figure out what it is. I guess that there is a subtle "defect", at least that
is the conclusion we came to. Since then I have piled so much other code into
the program that the crash is less important right now. Ultimately, I will
create it "in process" as an Add-In.
M&X wrote:
> I've had a look at your code... And got the same problem! (sorry)
>
> However, there is a big difference between what you do here and what I have
> done since now with the selection stuff: I have never done it in an external
> application till today.
> I've only used selections within add-ins and macros.
>
> While playing around with you code, I found out that if I call a MsgBox
> somewhere between the Loop (Do While bStillSelecting...) and the
> oInteractEvents.Stop I do not have any crash any more.
> My guess is that VB (or Inventor, or the API, or Windows, or all of them???)
> needs a kind of a break inbetween (but please, don't ask me why). I tried
> with a break and it worked... Except that my window does not come back in
> front (but I reckon that you know what to do with your SetForegroundWindow).
>
> So here is what I end up with:
>
> ...
> Do While bStillSelecting
> DoEvents
> Loop
> 'MsgBox "Thank you for selecting a Face!"
>
> ' Get the selected item. If more than one thing was selected,
> ' just get the first item and ignore the rest.
> Dim oSelectedEnts As ObjectsEnumerator
> Set oSelectedEnts = oSelectEvents.SelectedEntities
>
> If oSelectedEnts.Count > 0 Then
> Set Pick = oSelectedEnts.Item(1)
> Else
> Set Pick = Nothing
> End If
>
> Dim PauseTime, Start
>
> PauseTime = 0.5 ' Define the how long the pause will be.
> Start = Timer ' start time.
>
> Do While Timer < Start + PauseTime
> DoEvents ' Give control to other processes.
> Loop
>
> ' Stop the InteractionEvents object.
> oInteractEvents.Stop
> ...
>
> This works with me. Hope it does with you too.
>
> M(&X)
>
> "Charles Bliss" a écrit dans le message news:
> 3C07A8B9.7A60BDAE@cbliss.com...
> > So, what I am hearing is that it is only crashing for me. Both you and
> Patrick
> > have not suggested any problems with clsSelect per say yet when I run the
> code a
> > second time to set a second sketch, it crashes.
> >
> > I have posted a trimmed back version of the clsSelect and a form module to
> > Customer Files. If I run it, it will either crash on the first or second
> face
> > select. Any help would be greatly appreciated.
> >