Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Context Menu dropdown?

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
spencer
332 Views, 5 Replies

Context Menu dropdown?

I'm trying to add a dropdown menu to my right-click menu but I'm at a loss.

I'm looking to take the "Laser, Mill, Sol's" commands and put them in a flyout menu exactly like the BOM Structure commands.

spencer_0-1711397784485.png

I thought it might have just been using the "AddButtonPopup" function but that throws an error when I tried to add an object collection of those 3 button definitions. Not sure that style button can't be added to the context menu of if I messed up the function somehow.

5 REPLIES 5
Message 2 of 6
etaCAD
in reply to: spencer

For former versions of Inventor this was not possible to add a dropdown in a context menu.

I think it is still not possible in newer versions.

 

Andreas
etaCAD

Message 3 of 6
yuzeaa
in reply to: spencer

Take a look at this post.

Message 4 of 6
spencer
in reply to: yuzeaa

Still getting an error when I do it the way described in that post, happens when right-click and it tries to add the controls to the command bar. I even downloaded the .rar to look through that code and mine is functionally identical for all I can tell (My buttons are defined elsewhere and put into a 'contextButtons' list)

 

AddHandler m_inventorApplication.CommandManager.UserInputEvents.OnContextMenu,
            Sub(SelectionDevice As Inventor.SelectionDeviceEnum, AdditionalInfo As Inventor.NameValueMap, CommandBar As Inventor.CommandBar)
                If m_inventorApplication.ActiveDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
                    Dim SelectedEntities As SelectSet = m_inventorApplication.ActiveDocument.SelectSet
                    If SelectedEntities.Count > 0 Then
                        If TypeOf SelectedEntities(1) Is ComponentOccurrence Then
                            Dim CategoryButtons As CommandBar = m_inventorApplication.UserInterfaceManager.CommandBars.Add("Category", "CategoryCmd", CommandBarTypeEnum.kButtonPopupCommandBar)
                            CategoryButtons.Controls.AddButton(contextButtons("Laser"))
                            CategoryButtons.Controls.AddButton(contextButtons("Mill"))
                            CategoryButtons.Controls.AddButton(contextButtons("Sol's"))
                            CommandBar.Controls.AddPopup(CategoryButtons)

                        End If
                    End If
                End If
            End Sub

 

Message 5 of 6
yuzeaa
in reply to: spencer

you can't define commandbar with same internalname  everytime  rightclick.

6666.png

77777.png

Class ThisRule
	Dim contextButtons As New Dictionary(Of String,ButtonDefinition)
    Private CategoryButtons As CommandBar
	Sub main
        Dim oControls = ThisApplication.CommandManager.ControlDefinitions
		contextButtons.Add("Laser", oControls.AddButtonDefinition("Laser", "LaserCmd", CommandTypesEnum.kShapeEditCmdType))
		contextButtons.Add("Mill", oControls.AddButtonDefinition("Mill", "MillCmd", CommandTypesEnum.kShapeEditCmdType))
		contextButtons.Add("Sol's", oControls.AddButtonDefinition("Sol's", "Sol'sCmd", CommandTypesEnum.kShapeEditCmdType))
		CategoryButtons =ThisApplication.UserInterfaceManager.CommandBars.Add("Category", "CategoryCmd", CommandBarTypeEnum.kPopUpCommandBar)
		CategoryButtons.Controls.AddButton(contextButtons("Laser"))
		CategoryButtons.Controls.AddButton(contextButtons("Mill"))
		CategoryButtons.Controls.AddButton(contextButtons("Sol's"))
		
        AddHandler ThisApplication.CommandManager.UserInputEvents.OnContextMenu, AddressOf OnContextMenu
	End Sub
	
	Private Sub OnContextMenu(SelectionDevice As SelectionDeviceEnum, AdditionalInfo As NameValueMap, CommandBar As CommandBar)
        If ThisApplication.ActiveDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
            Dim SelectedEntities As SelectSet = ThisApplication.ActiveDocument.SelectSet
            If SelectedEntities.Count > 0 Then
                If TypeOf SelectedEntities(1) Is ComponentOccurrence Then
                    CommandBar.Controls.AddPopup(CategoryButtons)
                End If
            End If
        End If
    End Sub
End Class
Tags (1)
Message 6 of 6
spencer
in reply to: yuzeaa

Ah, didn't realize that was the case and it's working perfectly now, thanks.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report