Hi @ngdnam88. Placing the component at your mouse cursor is a whole other complex matter, that would need to involve multiple layers of events and a mode change. If placing the component at your mouse cursor is super important, then executing the command, and using the normal manual user interface tools is likely you best route. I don't think I have tried placing an assembly component at the position of my mouse pointer by code before, because we already have a built-in tool for doing it that way. Plus the mouse position routine just returns a Point objects, and the AddWithOptions wants a Matrix to dictate the position of the component.
Below is a quick example of how to get the mouse position.
Class ThisRule
Dim oIntEv As InteractionEvents
Dim oMouseEv As MouseEvents
Dim oMousePosition As Inventor.Point
Sub Main
oIntEv = ThisApplication.CommandManager.CreateInteractionEvents
oMouseEv = oIntEv.MouseEvents
AddHandler oMouseEv.OnMouseClick, AddressOf oMouseEv_OnMouseClick
Logger.Info("Just added the OnMouseClick event handler.")
oIntEv.Start
'now use that oMousePosition variable as you may need
End Sub
Sub oMouseEv_OnMouseClick(oMBtn As MouseButtonEnum, oShiftState As ShiftStateEnum, oMPos As Inventor.Point, oViewPos As Point2d, oView As Inventor.View)
MsgBox("Model Position = " & oMPos.X & " cm x " & oMPos.Y & " cm (from model origin)" & vbCrLf & _
"View Position = " & oViewPos.X & " x " & oViewPos.Y & " (from top left corner of view)", , "MOUSE POSITION")
oMousePosition = oMPos 'sets it to the 'common' variable outside of this routine
RemoveHandler oMouseEv.OnMouseClick, AddressOf oMouseEv_OnMouseClick
Logger.Info("Just removed the OnMouseClick event handler.")
End Sub
End Class
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)