Using Mouse Events using iLogic

Using Mouse Events using iLogic

nstone
Contributor Contributor
3,004 Views
9 Replies
Message 1 of 10

Using Mouse Events using iLogic

nstone
Contributor
Contributor

Hi guys,

I'm trying to get the point location of a mouse click in an Inventor drawing using an iLogic Rule.

 

Does any one have any examples of using mouse events in iLogic?

 

Thanks

0 Likes
3,005 Views
9 Replies
Replies (9)
Message 2 of 10

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

Hope the code below helps. Copy it to iLogic.

 


Sub Main()
 Dim oInteraction  As InteractionEvents 
 oInteraction = ThisApplication.CommandManager.CreateInteractionEvents

 Dim oMouse As MouseEvents
 oMouse = oInteraction.MouseEvents
  AddHandler oMouse.OnMouseDown  ,AddressOf oMouse_OnMouseDown 

  oInteraction.Start

 
End Sub

Sub oMouse_OnMouseDown(Button As MouseButtonEnum, ShiftKeys As ShiftStateEnum, ModelPosition As Point, ViewPosition As Point2d, view As View)
  MsgBox (Button)
End Sub


 

 

Message 3 of 10

Anonymous
Not applicable
Hi,
I would like use ilogic to select and replace a component in the assembly by using mouse selection. Whether it is possible by using ilogic

I have already posted my assembly file in the below link
http://forums.autodesk.com/t5/Autodesk-Inventor/ilogic-part-insertion/m-p/3667380

Need your input regarding this
Carthik
0 Likes
Message 4 of 10

Anonymous
Not applicable
0 Likes
Message 5 of 10

ekinsb
Alumni
Alumni

Did you try the CommandManager.Pick method?  If you just need a single item selected, this is much simpler than implementing events.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 6 of 10

Anonymous
Not applicable
Hi, Searched for the whole day to know how to handle commandmanager.pick method.....i found no solution to handle by ilogic...i found codes, that can be run by using VBA Editor. I am not familiar with VBA & Macros.
Can you please help me in creating the ilogic code to remove the component from the assembly by selection, the assembly file is available in the below link
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/ilogic-to-handle-mouse-event-for-part-...
Need help regarding the same..
0 Likes
Message 7 of 10

philippe.leefsma
Alumni
Alumni

Question was solved in the following post

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 8 of 10

Anonymous
Not applicable

Hi, can you post ilogic to get XYZ positon of the mouse, when the mousedownbutton is 1. I would like to place component in an assembly based on mouse position on click. 

 

Regards,

Carthik

0 Likes
Message 9 of 10

philippe.leefsma
Alumni
Alumni

You can't do that in iLogic, retrieving mouse coordinates requires the use of InteractionEvents, this is an API functionality that needs events and iLogic doesn't support events.

 

In the API Help Files you can find complete examples on how to use InteractionEvents.

 

Le me know if you have more specific questions about the use of the API.

 

Regards,

Philippe.

 

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 10 of 10

Anonymous
Not applicable

Dear Sir,

 

I got the solution to place component based on mouse click, based on the above code by xiaodong.liang

 

Sub Main()
Dim oInteraction As InteractionEvents
oInteraction = ThisApplication.CommandManager.CreateInteractionEvents

Dim oMouse As MouseEvents
oMouse = oInteraction.MouseEvents
AddHandler oMouse.OnMouseDown ,AddressOf oMouse_OnMouseDown

oInteraction.Start


End Sub

Sub oMouse_OnMouseDown(Button As MouseButtonEnum, ShiftKeys As ShiftStateEnum, ModelPosition As Point, ViewPosition As Point2d, view As View)
'MsgBox (Button)
Posx=ModelPosition.X
Posy=ModelPosition.Y
Posz=ModelPosition.Z

' Create a matrix.
Dim oMatrix As Matrix
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
oMatrix = oTG.CreateMatrix
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oOccurrence As ComponentOccurrence
oFile = "X:\Pipe Clamp & Liner Assembly - Manual.iam"
oMatrix.SetTranslation(oTG.CreateVector(Posx, Posy, Posz))
oOccurrence = oAsmCompDef.Occurrences.Add(oFile, oMatrix)



End Sub

 

0 Likes