CommandManager.Pick (KDrawingWeldSymbol) Inventor 2024

CommandManager.Pick (KDrawingWeldSymbol) Inventor 2024

bradeneuropeArthur
Mentor Mentor
677 Views
5 Replies
Message 1 of 6

CommandManager.Pick (KDrawingWeldSymbol) Inventor 2024

bradeneuropeArthur
Mentor
Mentor

How can I use the the commandmanager to select/pick a DrawingWeldingSymbol in Inventor 2024. The API now is available for DrawingWeldSymbols, but not for selection?

 

Any Ideas how to select these?

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
Accepted solutions (1)
678 Views
5 Replies
Replies (5)
Message 2 of 6

Michael.Navara
Advisor
Advisor

It looks like a bug. You can process only pre-selected symbols. Selection doesn't work in SelectEvents too.

According to this StackOverflow post I try to implement custom functionality similar to Pick method. But it doesn't work with drawing weld symbols. 😞

 

 

imports system.Threading.Tasks
Sub Main()
MainAsync()
End Sub

Private pickTcs As TaskCompletionSource(Of Boolean) = New TaskCompletionSource(Of Boolean)()
Private interactionEvts As InteractionEvents
Private selectEvts As SelectEvents

Async Sub MainAsync()
	interactionEvts = ThisApplication.CommandManager.CreateInteractionEvents()
	selectEvts = interactionEvts.SelectEvents

	AddHandler interactionEvts.OnTerminate, AddressOf interactionEvts_OnTerminate
	AddHandler selectEvts.OnSelect, AddressOf selectEvts_OnSelect

	interactionEvts.Start()

	Dim selectedSomething = Await pickTcs.Task
	Logger.Debug("Something selected: {0}", selectedSomething)
End Sub

Private Sub selectEvts_OnSelect(justSelectedEntities As ObjectsEnumerator, selectionDevice As SelectionDeviceEnum, modelPosition As Point, viewPosition As Point2d, view As Inventor.View)

	pickTcs.SetResult(True)
	StopInteraction()
End Sub

Private Sub interactionEvts_OnTerminate()
	pickTcs.SetResult(False)
	StopInteraction()
End Sub

Private Sub StopInteraction()
	interactionEvts.Stop()
	interactionEvts = Nothing
	selectEvts = Nothing
End Sub

 

 

Message 3 of 6

bradeneuropeArthur
Mentor
Mentor

Hi Michael,

I was trying exact the same but no result. Seems as a bug indeed.

@johnsonshiue could you and your team have a look at it?

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 6

Michael.Navara
Advisor
Advisor
Accepted solution

I found a solution! 😀

 

 

 

Imports System.Threading.Tasks

Sub Main()
MainAsync()
End Sub

Private pickTcs As TaskCompletionSource(Of Boolean) = New TaskCompletionSource(Of Boolean)()
Private userInputEvts As UserInputEvents
Private pickedObject As Object

Async Sub MainAsync()

	userInputEvts = ThisApplication.CommandManager.UserInputEvents
	AddHandler userInputEvts.OnSelect, AddressOf userInputEvts_OnSelect
	Dim selectedSomething = Await pickTcs.Task

	If (selectedSomething) Then
		Logger.Debug("Something selected: {0}", selectedSomething)
	End If

	Dim drwWeldSymbol As DrawingWeldingSymbol = TryCast(pickedObject, DrawingWeldingSymbol)
	If (Not drwWeldSymbol Is Nothing) Then
		Logger.Debug("DrawingWeldingSymbol picked")
	End If
End Sub

Private Sub userInputEvts_OnSelect(justSelectedEntities As ObjectsEnumerator, ByRef moreSelectedEntities As ObjectCollection, selectionDevice As SelectionDeviceEnum, modelPosition As Point, viewPosition As Point2d, view As Inventor.View)
	If (justSelectedEntities.Count > 0) Then
		pickedObject = justSelectedEntities(1)
		RemoveHandler userInputEvts.OnSelect, AddressOf userInputEvts_OnSelect
		pickTcs.SetResult(True)
	End If
End Sub
		

 

 

 

Message 5 of 6

bradeneuropeArthur
Mentor
Mentor

@Michael.Navara ,

Good job thanks.

I have learned something new also.

Where did you find this, or how did you come to this idea?

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 6

Michael.Navara
Advisor
Advisor

I know there are two events for selection UserInputEvents.OnSelect and SelectEvents.OnSelect both of them I used before. The first one is useful when you need to process any (relevant) entity selected by user, the second one is useful when you need to control what can be selected. 

The rest is an implementation of  StackOverflow post mentioned above.

And also I like this challenges.

I hope it helps.