Place prompted text at cursor like with commandmanager.pick

Place prompted text at cursor like with commandmanager.pick

bradeneuropeArthur
Mentor Mentor
416 Views
6 Replies
Message 1 of 7

Place prompted text at cursor like with commandmanager.pick

bradeneuropeArthur
Mentor
Mentor

How to place prompted text at cursor like CommandManager.Pick does, via vba/vba.net/ilogic?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
417 Views
6 Replies
Replies (6)
Message 2 of 7

JelteDeJong
Mentor
Mentor

You can implement your version of the method: "commandmanager.pick". Then you have more options too. something like this:

Public Class ThisRule
    Public Sub main()

        Dim selector As New Selector(ThisApplication)
        selector.MousePointerText = "Test test"
        selector.Filter = ObjectTypeEnum.kLinearGeneralDimensionObject
        selector.CursorType = CursorTypeEnum.kCursorBuiltInDynpan
        selector.Pick()

        Dim firstSelectedObject = selector.SelectedObjects.Item(1)
        Dim type = CType(firstSelectedObject.Type, ObjectTypeEnum)
        MsgBox(type.ToString())

    End Sub
End Class

Public Class Selector
    Private WithEvents _interactEvents As InteractionEvents
    Private WithEvents _selectEvents As SelectEvents
    Private _stillSelecting As Boolean
    Private _inventor As Inventor.Application

    Public Sub New(ThisApplication As Inventor.Application)
        _inventor = ThisApplication
    End Sub

    Public Sub Pick()
        _stillSelecting = True

        _interactEvents = _inventor.CommandManager.CreateInteractionEvents
        _interactEvents.InteractionDisabled = False
        _interactEvents.StatusBarText = MousePointerText
        '                     ^-- This will also set the mousepointer text
        _interactEvents.SetCursor(CursorType)

        _selectEvents = _interactEvents.SelectEvents
        _selectEvents.WindowSelectEnabled = False

        _interactEvents.Start()
        Do While _stillSelecting
            _inventor.UserInterfaceManager.DoEvents()
        Loop
        _interactEvents.Stop()

        _inventor.CommandManager.StopActiveCommand()
    End Sub

    Public Property SelectedObjects As ObjectsEnumerator = Nothing
    Public Property MousePointerText As String = "Select ..."
    Public Property CursorType As CursorTypeEnum = CursorTypeEnum.kCursorTypeDefault
    Public Property Filter As ObjectTypeEnum = Nothing

    Private Sub selectEvents_OnPreSelect(
            ByRef PreSelectEntity As Object,
            ByRef DoHighlight As Boolean,
            ByRef MorePreSelectEntities As ObjectCollection,
            SelectionDevice As SelectionDeviceEnum,
            ModelPosition As Inventor.Point,
            ViewPosition As Point2d,
            View As Inventor.View) Handles _selectEvents.OnPreSelect

        DoHighlight = False

        If (Filter = Nothing) Then
            DoHighlight = True
        End If
        Try
            If (PreSelectEntity.Type = Filter) Then
                DoHighlight = True
            End If
        Catch ex As Exception
        End Try
    End Sub

    Private Sub selectEvents_OnSelect(
            ByVal JustSelectedEntities As ObjectsEnumerator,
            ByVal SelectionDevice As SelectionDeviceEnum,
            ByVal ModelPosition As Inventor.Point,
            ByVal ViewPosition As Point2d,
            ByVal View As Inventor.View) Handles _selectEvents.OnSelect

        SelectedObjects = JustSelectedEntities
        _stillSelecting = False
    End Sub

    Private Sub interactEvents_OnTerminate() Handles _interactEvents.OnTerminate
        _stillSelecting = False
    End Sub
End Class

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 3 of 7

bradeneuropeArthur
Mentor
Mentor

Hi @JelteDeJong 

Thanks for the suggestion.

I have seen that already via the "InteractionEvents", but that is not what I am searching for.

The "InteractionEvents" do not work for my needs since the selection is not part of the API, therefor not selectable.

Do you know another way to do is without that any action I can put text on the cursor.

 

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 4 of 7

JelteDeJong
Mentor
Mentor

 The InteractionEvents are very powerful and I expect that it can select anything in the Inventor environment. Can you tell me a bit more about the things that you are trying to select?

 

In the past, I did have a case where I needed to make a selection that distinguished between the dimension line and extension lines (of a dimension). That is not possible with the standard selection API but I managed to do it with the InteractionEvents. I wrote a blog post about it "Selecting dimensions".

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 5 of 7

bradeneuropeArthur
Mentor
Mentor

Hi @JelteDeJong 

I try to select the weldsymbol in Inventor 2024. These are now part of the API. But the interaction events are not working for these, because they are not part of the filter (typeenum).

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 6 of 7

JelteDeJong
Mentor
Mentor

I found a way to (sort of) select the welding symbols. It's an ugly hack but it works. The preselect event recognises the "DrawingWeldSymbol". I expect that it's a bug that it isn't recognised by the select event. You can work around this by saving the preselected object in a property and wait for the select interaction to end. This can be done like this: User clicks on the weld symbol and presses "esc" key. (What do you think about it?)

JelteDeJong_0-1701731635811.png

 

Public Class ThisRule
    Public Sub main()

        Dim selector As New Selector(ThisApplication)
        selector.Pick()

        Dim weldSymbol As DrawingWeldingSymbol = selector.SelectedObject

        MsgBox(weldSymbol.Definitions.Item(1).TailNote)
    End Sub
End Class

Public Class Selector
    Private WithEvents _interactEvents As InteractionEvents
    Private WithEvents _selectEvents As SelectEvents
    Private _stillSelecting As Boolean
    Private _inventor As Inventor.Application

    Public Sub New(ThisApplication As Inventor.Application)
        _inventor = ThisApplication
    End Sub

    Public Sub Pick()
        _stillSelecting = True

        _interactEvents = _inventor.CommandManager.CreateInteractionEvents
        _interactEvents.InteractionDisabled = False
        _interactEvents.StatusBarText = MousePointerText
        '                     ^-- This will also set the mousepointer text
        _interactEvents.SetCursor(CursorType)

        _selectEvents = _interactEvents.SelectEvents
        _selectEvents.WindowSelectEnabled = False

        _interactEvents.Start()
        Do While _stillSelecting
            _inventor.UserInterfaceManager.DoEvents()
        Loop
        _interactEvents.Stop()

        _inventor.CommandManager.StopActiveCommand()
    End Sub

    Public Property SelectedObject As DrawingWeldingSymbol = Nothing
    Public Property MousePointerText As String = "Select ..."
    Public Property CursorType As CursorTypeEnum = CursorTypeEnum.kCursorTypeDefault
    Public Property Filter As ObjectTypeEnum = Nothing

    Private Sub selectEvents_OnStopPreSelect(ModelPosition As Point, ViewPosition As Point2d, View As View) Handles _selectEvents.OnStopPreSelect
        _interactEvents.StatusBarText = "..."
    End Sub

    Private Sub selectEvents_OnPreSelect(
            ByRef PreSelectEntity As Object,
            ByRef DoHighlight As Boolean,
            ByRef MorePreSelectEntities As ObjectCollection,
            SelectionDevice As SelectionDeviceEnum,
            ModelPosition As Inventor.Point,
            ViewPosition As Point2d,
            View As Inventor.View) Handles _selectEvents.OnPreSelect

        DoHighlight = False

        _interactEvents.StatusBarText = Microsoft.VisualBasic.Information.TypeName(PreSelectEntity)

        If (TypeOf PreSelectEntity Is DrawingWeldingSymbol) Then
            _interactEvents.StatusBarText = "DrawingWeldingSymbol has been found!!! (press escape to continue.)"
            SelectedObject = PreSelectEntity
            DoHighlight = True
        End If
    End Sub

    Private Sub selectEvents_OnSelect(
            ByVal JustSelectedEntities As ObjectsEnumerator,
            ByVal SelectionDevice As SelectionDeviceEnum,
            ByVal ModelPosition As Inventor.Point,
            ByVal ViewPosition As Point2d,
            ByVal View As Inventor.View) Handles _selectEvents.OnSelect

        SelectedObject = JustSelectedEntities
        _stillSelecting = False
    End Sub

    Private Sub interactEvents_OnTerminate() Handles _interactEvents.OnTerminate
        _stillSelecting = False
    End Sub
End Class

 

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 7 of 7

bradeneuropeArthur
Mentor
Mentor

Thanks @JelteDeJong ,

But that will not work for me at the moment.

@johnsonshiue could you or your team have a look at the missing object in the API for WeldSymbols, so that we can also use the CommandManagerPick event for WeldSymbols.

Thans in advance,

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes