Generic Buttons handler in Inventor

Generic Buttons handler in Inventor

woodstylee3
Advocate Advocate
324 Views
3 Replies
Message 1 of 4

Generic Buttons handler in Inventor

woodstylee3
Advocate
Advocate

I'm trying to write a generic button handler for Inventor 2015/2016 in VB.NET 4.5 , that handles genertae multiple icons, and then opens a file from the help menu, to start with I have created a variable as a list of buttons...

 

Private WithEvents ss_help_buttons As New System.Collections.Generic.List(Of Inventor.ButtonDefinition)

 

I then poulate the controls from a generic list of some data, and link the buttons to the handler.

 

Private Sub load_help_menus()

m_uimanager.HelpControls.AddSeparator()

Dim ctr As Integer = 0

Do While ctr < GlobalVars.m_project_file.HelpLinks.Count

Dim new_menu_help_link As Inventor.ButtonDefinition

new_menu_help_link = m_controldefs.AddButtonDefinition(GlobalVars.m_project_file.HelpLinks(ctr).Value.DisplayName, "SOUPIPROPMAN_HELPLINKS_" & ctr.ToString, CommandTypesEnum.kQueryOnlyCmdType, GlobalVars.m_clientId)

AddHandler new_menu_help_link.OnExecute, AddressOf ss_help_run

ss_help_buttons.Add(new_menu_help_link)

m_uimanager.HelpControls.AddButton(ss_help_buttons.Item(ctr))

ctr = ctr + 1

Loop

End Sub

 

All works well so far and the handler below is triggered when the button is pressed.

 

Private Sub ss_help_run(context As Inventor.NameValueMap)

Dim n As Integer = 1 'Does nothing just serves a line to break on

End Sub

 

So my question is, is there any way to get a handle to which button was pressed from inside the handler? (I have interogated "Context" when debugging and can't find any useful data attached.

 

Thanks

 

 

 

 

0 Likes
325 Views
3 Replies
Replies (3)
Message 2 of 4

mikazakov
Advocate
Advocate

 You can't created array or list of WithEvents: see msdn:

 

https://msdn.microsoft.com/en-us/library/aty3352y(v=vs.90).aspx

 

If you want to use list of ButtonDefinition, you should write:

 

Private ss_help_buttons As New System.Collections.Generic.List(Of Inventor.ButtonDefinition)

 

0 Likes
Message 3 of 4

woodstylee3
Advocate
Advocate

Interesting... Compiles and runs OK... I'd had to steer away from Arrays, but the list seems to work.

 

The event is firing (which is what I want). I just can't seem to find which button in the list fired the event. Was hoping the context parameter would have similar data attached to the sender variable in windows controls, but on face value appears not.

 

 

0 Likes
Message 4 of 4

mikazakov
Advocate
Advocate

Its really, the Context.Count=0

May be its bug.... may be "product limitation".

you can try to write bug report to beta forum of Inventor.

0 Likes