Jump to content

RE: Need help in Inventor VBA


Recommended Posts

Posted

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.CreateInteractionEvents

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:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...