Override a shortcut used by a built-in command using API

Override a shortcut used by a built-in command using API

DRoam
Mentor Mentor
472 Views
2 Replies
Message 1 of 3

Override a shortcut used by a built-in command using API

DRoam
Mentor
Mentor

If I go to Customize --> Keyboard tab, find the "Line" command, and try to set its shortcut to "Ctrl+Shift+L", I'm told that "Ctrl+Shift+L" is currently assigned to "Loft [Sketched Features]", and I can click "Yes" to override and take the assignment from the Loft command.

 

I'm trying to figure out how to do the same thing but through the API.

 

I can use the following snippet to set the line command's shortcut to something like "Ctrl+L", or "Ctrl+Alt+L":

 

Dim oLineDef As Inventor.ControlDefinition = ThisApplication.CommandManager.ControlDefinitions("SketchLineCmd")
oLineDef.OverrideShortcut = "Ctrl+Shift+L"

However, when I try to set it to Ctrl+Shift+L, I get an error. Presumably because the shortcut belongs to the Loft command.

 

I tried preceding the code above with this, to remove the Ctrl+Shift+L shortcut from Loft first:

Dim oLoftDef As Inventor.ControlDefinition = ThisApplication.CommandManager.ControlDefinitions("PartLoftCmd")
oLoftDef.OverrideShortcut = "LO"

... and it does change the shortcut shown for Loft in the Customize dialog, but apparently, Ctrl+Shift+L is still tied to the loft command under the hood. So the assignment of Ctrl+Shift+L to the line command still fails.

 

How can I completely unassign Ctrl+Shift+L from the Loft command using the API, so that I can assign it to the Line command using the API?

0 Likes
473 Views
2 Replies
Replies (2)
Message 2 of 3

bradeneuropeArthur
Mentor
Mentor

what do the messageboxes show?

 

Public Sub shortcut()

Dim oLineDef As Inventor.ControlDefinition
Set oLineDef = ThisApplication.CommandManager.ControlDefinitions("SketchLineCmd")
'oLineDef.OverrideShortcut = "Ctrl+Shift+L"
MsgBox oLineDef.DefaultShortcut
Dim oLoftDef As Inventor.ControlDefinition
Set oLoftDef = ThisApplication.CommandManager.ControlDefinitions("PartLoftCmd")
'oLoftDef.OverrideShortcut = "LO"
MsgBox oLoftDef.DefaultShortcut
End Sub

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 3

DRoam
Mentor
Mentor

Loft's "DefaultShortcut" is "LO", according to the API. Which is odd because it's actually not, it's "Ctrl+Alt+L".

 

Line's "DefaultShortcut" is blank, according to the API. Which is also odd because it's actually "L".

 

I can't find method or property of the ControlDefinition for Loft that is aware of the assignment to Ctrl+Alt+L, or can de-assign it. Surely I'm missing something...

0 Likes