Grouped Custom Commands in Context Menu

Grouped Custom Commands in Context Menu

spencer
Advocate Advocate
1,245 Views
9 Replies
Message 1 of 10

Grouped Custom Commands in Context Menu

spencer
Advocate
Advocate

Hopefully there's a simple answer for this, but I'm trying to make a group of commands in the context menu but haven't had any luck. Doing everything through a VB.NET addin, commands are being added just fine on their own but I wanted to group some of that were related to each other (ie. a main command and come copies with different arguments).

Really I want it to be like the Component drop-down shown.

 2019-07-02 14_17_00-Marking Menu.png

Any suggestions?

0 Likes
Accepted solutions (1)
1,246 Views
9 Replies
Replies (9)
Message 2 of 10

bradeneuropeArthur
Mentor
Mentor

Could you post your code that you are having that far?

 

Regards,

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 3 of 10

spencer
Advocate
Advocate

The entirety has a lot going on, but the important bits are like this:

 

'Stuff

Private WithEvents OriginConstrainCmd As Inventor.ButtonDefinition Private WithEvents OriginConstrainCmdNX As Inventor.ButtonDefinition Private WithEvents OriginConstrainCmdNY As Inventor.ButtonDefinition Private WithEvents OriginConstrainCmdNZ As Inventor.ButtonDefinition

'More stuff
OriginConstrainCmd = objControlDefs.AddButtonDefinition("Origin Constrain", "OriginConstrainCmd", CommandTypesEnum.kQueryOnlyCmdType,,, "Constrains origins of selected parts to first selection.")
OriginConstrainCmdNX = objControlDefs.AddButtonDefinition("Exclude X Plane", "OriginConstrainCmdNX", CommandTypesEnum.kQueryOnlyCmdType,,, "")
OriginConstrainCmdNY = objControlDefs.AddButtonDefinition("Exclude Y Plane", "OriginConstrainCmdNY", CommandTypesEnum.kQueryOnlyCmdType,,, "")
OriginConstrainCmdNZ = objControlDefs.AddButtonDefinition("Exclude Z Plane", "OriginConstrainCmdNZ", CommandTypesEnum.kQueryOnlyCmdType,,, "")

'More Stuff
Private Sub addin_OnLinearContextMenu(SelectedEntities As ObjectsEnumerator, SelectionDevice As SelectionDeviceEnum, LinearMenu As CommandControls, AdditionalInfo As NameValueMap)
LinearMenu.AddButton(OriginConstrainCmd)
LinearMenu.AddButton(OriginConstrainCmdNX)
LinearMenu.AddButton(OriginConstrainCmdNY)
LinearMenu.AddButton(OriginConstrainCmdNZ)
End Sub

Commands themselves work fine, but on the Linear Menu object trying to use the other methods (AddButtonPopup, AddPopup, AddComboBox, AddSplitButton) all fail with a 'not implemented' error 

0 Likes
Message 4 of 10

bradeneuropeArthur
Mentor
Mentor
Private WithEvents OriginConstrainCmd As Inventor.ButtonDefinition
Private WithEvents OriginConstrainCmdNX As Inventor.ButtonDefinition
Private WithEvents OriginConstrainCmdNY As Inventor.ButtonDefinition
Private WithEvents OriginConstrainCmdNZ As Inventor.ButtonDefinition

'More stuff
OriginConstrainCmd = objControlDefs.AddButtonDefinition("Origin Constrain", "OriginConstrainCmd", CommandTypesEnum.kQueryOnlyCmdType,,, "Constrains origins of selected parts to first selection.")
OriginConstrainCmdNX = objControlDefs.AddButtonDefinition("Exclude X Plane", "OriginConstrainCmdNX", CommandTypesEnum.kQueryOnlyCmdType,,, "")
OriginConstrainCmdNY = objControlDefs.AddButtonDefinition("Exclude Y Plane", "OriginConstrainCmdNY", CommandTypesEnum.kQueryOnlyCmdType,,, "")
OriginConstrainCmdNZ = objControlDefs.AddButtonDefinition("Exclude Z Plane", "OriginConstrainCmdNZ", CommandTypesEnum.kQueryOnlyCmdType,,, "")

'More Stuff
Private Sub addin_OnLinearContextMenu(SelectedEntities As ObjectsEnumerator, SelectionDevice As SelectionDeviceEnum, LinearMenu As CommandControls, AdditionalInfo As NameValueMap)
  
Dim a As ObjectCollection
a = ThisApplication.TransientObjects.CreateObjectCollection
a.Add(OriginConstrainCmd)
a.Add(OriginConstrainCmdNX)
a.Add(OriginConstrainCmdNY)
a.Add(OriginConstrainCmdNZ)


LinearMenu.AddSplitButton(OriginConstrainCmd,a, True, True, "BEFORE WHAT", True)
'''''''''else LinearMenu.AddSplitButton(OriginConstrainCmd,a, True, True,) End Sub

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 5 of 10

spencer
Advocate
Advocate

No dice unfortunately, still throwing exceptions on right-click.

System.NotImplementedException: 'Not implemented (Exception from HRESULT: 0x80004001 (E_NOTIMPL))'
0 Likes
Message 6 of 10

bradeneuropeArthur
Mentor
Mentor

also if you declare the buttondef as object

like dim OriginConstrainCmd as object

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 7 of 10

spencer
Advocate
Advocate

Neither declaring nor direct casting as an object seemed to make any difference

0 Likes
Message 8 of 10

etaCAD
Advocate
Advocate
Accepted solution

A few years ago I tried as well to add grouped commands to the context menu and did many tests but there was no solution. This was not supported by the API.

Unfortunately, I think nothing changed so far.

 

Andreas
etaCAD

Message 9 of 10

bradeneuropeArthur
Mentor
Mentor

Hi @etaCAD ,

 

I remember that too.

For the Context menu this is not supported.

For the Ribbon and the menu's it is possible.

 

Regards,

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 10 of 10

spencer
Advocate
Advocate

Figured that might be the case. At least I know for sure and stop trying to find a way to make it work

0 Likes