Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Code below works perfect in IV 2009 but doesn't work in IV 2011. Both running on Windows XP 64bit. All the program does is by running the TestSelection Sub the user clicks on Inventor screen and the code will place WorkPoints (Must have an assembly doc open). User hits esc button to quit. Very simple and works great in 2009 but with 2011 once the code hits the oInteractEvents.Start the oInteractEvents_OnTerminate() event gets triggered for no reason. Anyone know why? Planning on upgrading but always find something that prevents me from doing so.
thanks, Chuck
Public Sub TestSelection()
Call SetToTopView
Dim clsPick As New clsSelect
clsPick.WaitForClick
End Sub
Sub SetToTopView()
Dim oView As View
Set oView = ThisApplication.ActiveView
Dim oCamera As Camera
Set oCamera = oView.Camera
oCamera.ViewOrientationType = kTopViewOrientation
oCamera.Apply
End Sub
'Class module code
Private WithEvents oInteractEvents As InteractionEvents
Private WithEvents oMouseEvents As MouseEvents
Private bStillSelecting As Boolean
Public Function WaitForClick() As Variant
bStillSelecting = True
Set oInteractEvents = ThisApplication.CommandManager.CreateInteractionEvents
oInteractEvents.SelectionActive = True
Set oMouseEvents = oInteractEvents.MouseEvents
oMouseEvents.PointInferenceEnabled = True
oMouseEvents.MouseMoveEnabled = False
oInteractEvents.Start
Do While bStillSelecting
DoEvents
Loop
oInteractEvents.Stop
Set oMouseEvents = Nothing
Set oInteractEvents = Nothing
End Function
Private Sub oInteractEvents_OnTerminate()
bStillSelecting = False
MsgBox "Adding work points complete."
End Sub
Private Sub oMouseEvents_OnMouseClick(ByVal Button As MouseButtonEnum, ByVal ShiftKeys As ShiftStateEnum, ByVal ModelPosition As Point, ByVal ViewPosition As Point2d, ByVal View As View)
Dim oPickPoint As Point
Set oPickPoint = ModelPosition
oPickPoint.Y = -0.5 * 2.54
Dim oAssy As AssemblyDocument
Set oAssy = ThisApplication.ActiveDocument
Dim aPoint As WorkPoint
Set aPoint = oAssy.ComponentDefinition.WorkPoints.AddFixed(oPickPoint)
aPoint.Name = "FP " & aPoint.Name
End Sub
Solved! Go to Solution.