Looking for a Way to Trigger iLogic Rules via Shortcut—Possible?

Looking for a Way to Trigger iLogic Rules via Shortcut—Possible?

k.hendrickx
Advocate Advocate
243 Views
2 Replies
Message 1 of 3

Looking for a Way to Trigger iLogic Rules via Shortcut—Possible?

k.hendrickx
Advocate
Advocate

Hi all,

 

I believe I already know the answer based on some research, but I wanted to check with the Inventor iLogic experts here to be sure.

 

From what I’ve found, it seems there's no way to assign keyboard shortcuts or right-click marking menus directly to an (external) iLogic rule—unless you use VBA as an intermediary. Is that correct?

 

It just feels counterintuitive that this kind of integration works seamlessly with VBA macros but not with Autodesk’s own scripting language, iLogic.

Thankfully, I managed to create toolbar buttons for my scripts, but still—Autodesk, why can’t we assign a simple shortcut to a rule?

 

I can understand the limitation with local rules, since they’re document-specific and not always loaded, but what’s stopping us from doing this with external rules?

0 Likes
Accepted solutions (1)
244 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

Hi @k.hendrickx.  Which version/year of Inventor are you using?  I believe it was either in the 2023 or 2024 release of Inventor Professional where they started allowing is to directly place iLogic rules into the ribbon, in the 'User Commands' panel, without needing to use a 'VBA macro'.  Since a 'ButtonDefinition' is automatically being created for those 'rule buttons', we can set a shortcut (ButtonDefinition.DefaultShortcut) for executing the 'ControlDefinition' behind the button.  For example, I created a simple external iLogic rule named "Show DisplayName", then placed that into the ribbon as a rule button.  Then I opened the Customize dialog box, clicked on the 'Keyboard' tab, then scrolled down to where that control was listed, and selected the row it is on, to the left of its name (in the 'Keys' column), then pressed the Ctrl + Alt + D keyboard combination, and it set that as its shortcut.  Then I clicked on the Apply/OK button to exit out of the Customize dialog.  Then I pressed that key combination, and that rule ran, showing me the current document's DisplayName, as expected.

Before we were able to directly add external iLogic rules into the ribbon, without using VBA macros, we could still create custom button definitions and add them into the ribbon, even if only temporarily, then use an 'event handler' for its OnExecute event to run an external iLogic rule.  But all that stuff had to be managed by us, so to speak, which was complicated to manage with just iLogic rules, but could more easily be done with something like an Add-In, which starts when Inventor starts.

Edit:  Actually, when we do that through the Customize > Keyboard dialog, that is setting the ButtonDefinition.OverrideShortcut property's value to "Alt+Ctrl+D", and its ButtonDefinition.OverrideShortcutType would automatically get set to the "kAcceleratorShortcut" variation of the ShortcutTypeEnum.  I think the DefaultShortcut property may need to be set when the control was first created, if at all, but I never used the shortcuts much for iLogic rule buttons because clicking them was convenient enough for me.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 3

k.hendrickx
Advocate
Advocate

Oh my... You just made my day @WCrihfield ...

I can't believe I never tried to just scroll down the list to see if they were listed anyway.
In the ribbon the iLogic rules get their own category, but with the keyboard I could only find one for macros.

Seems, though, that they get listed under Add-Ins.

khendrickx_0-1745932338151.png

 

So, apparently the only smart thing I did today was ask you guys anyway.🤣

 

Edit: the biggest reason why I like shortcuts over buttons is that you can actually "queue" hotkeys while the script is running. Once the script is done, it will immediately do the next hotkey. Which can be a serious time saver.

For example, a drawing. I hit CTRL+S, CTRL+P, Enter, CTRL+W, CTRL+SHIFT+E, CTRL+SHIFT+R, and CTRL+SHIFT+V.

Which does a chain of 6 actions one after the other, while I go and grab a cup of coffee 😁