PDA

View Full Version : RE: Need help in Inventor VBA



allenliuyy
2nd Nov 2009, 08:11 pm
In Inventor part sketch mode, how can I get a mouse click point and show this point in the sketch plan by VBA?

I have some codes as following, but still need help to finish it.

Thank you in advance.

Form:

Private Sub cmdClickSketchScreen_Click()

Dim oApp As Inventor.Application
Dim oDoc As PartDocument
Dim oSketch As PlanarSketch
Dim oTransGeom As TransientGeometry
Dim oTrans As Transaction

Dim oClick As New clsClick
Dim oPoint2d As Point2d
Dim oPoints As SketchPoint

Set oPoint2d = oClick.Click(kLeftMouseButton) ' how to transfer this click to a point???
Set oPoints = oSketch.SketchPoints.Add(oPoint2d, True)

End sub




Class Module: clsClick

Private WithEvents oInteraction As InteractionEvents
Private WithEvents oMouseEvents As MouseEvents

Public Function Click(filter As MouseButtonEnum) As Object
Set oInteraction = ThisApplication.CommandManager.CreateInteractionEv ents
Set oMouseEvents = oInteraction.MouseEvents
oMouseEvents.MouseMoveEnabled = True
oInteraction.Start
End Function

Private Sub oMouseEvents_OnMouseClick(ByVal Button As MouseButtonEnum, _
ByVal ShiftKeys As ShiftStateEnum, _
ByVal ModelPosition As Point, ByVal ViewPosition As Inventor.Point2d, _
ByVal View As View)
End Sub
:geek: