Q:
How can I set custom cursor to be displayed during object selection for custom command?
A:
Object selection for Inventor custom command is done using InteractionEvents object and SelectEvents. The application creates new instance of InteractionEvents object using CommandManager.CreateInteractionEvents method. The object provides SetCursor method to set cursor for the command in which interaction is active.
To display custom cursor it's necessary to use CursorTypeEnum.kCursorTypeCustom as first parameter. The second parameter is full path to cursor file (cur). Third parameter indicates location of the hotspot relative to the cursor.
Below is the VB.Net code to achieve that. The cursor files need to be placed in same folder as the add-in dll in that case.
' members
Private _interactionEvents As Inventor.InteractionEvents
Private _selectEvents As Inventor.SelectEvents
Private Sub StartInteraction()
Dim app As Application = AddInServer.Instance.Application
_interactionEvents = app.CommandManager.CreateInteractionEvents()
' add delegates
AddHandler _interactionEvents.OnTerminate, _
AddressOf InteractionEvents_OnTerminate
' subscribe to recive select events
_selectEvents = _interactionEvents.SelectEvents
' add delegates
AddHandler _selectEvents.OnSelect, _
AddressOf SelectEvents_OnSelect
' set prompts and cursor
_interactionEvents.SetCursor( _
Inventor.CursorTypeEnum.kCursorTypeCustom, _
"MyCustomCursor.cur", _
Inventor.CursorHotSpotEnum.kCursorHotSpotDefault)
_interactionEvents.StatusBarText = "Select Face"
' selection filter
_selectEvents.SingleSelectEnabled = True
_selectEvents.ClearSelectionFilter()
_selectEvents.AddSelectionFilter_
(Inventor.SelectionFilterEnum.kPartFaceFilter)
' start interaction
_interactionEvents.Start()
End Sub