By Clint Brown
A common request from Inventor users, is the ability to run iLogic rules from Inventor’s Ribbon interface. Unfortunately, this is not possible using iLogic alone. But the good news, is that Inventor has a built in VBA editor, and Macros created in this editor can be added to the Ribbon Interface.
To create a button for an iLogic rule on the ribbon, you will need to create a VBA macro in Inventor that will fire an iLogic rule. Once the Macro is created, you can add it to the Ribbon.
Firstly,make a backup copy of the following file: C:\Users\Public\Documents\Autodesk\Inventor 2017\Default.ivb
Then paste the code from the attached text file into your VBA editor under "Module 1" as shown.
I've set the code in the text file to look for an internal rule named "Rule0", you can change this to match your rule name. The code can be adjusted for an external rule. The external rule in this instance is set to "3D PDF" (based on a rule from a previous blog post). The external rule is currently commented out, in favour of the internal rule (see the last 3 lines of code).
Adding the Button to the Ribbon:
To add your macro to the ribbon, right click on the ribbon, and select "Customise User Commands" then select "Macros" from the drop down menu on the left hand side. You can add your macro to the ribbon, as shown below. Note the options for size and text (see the section on Button icons below).
The Inventor .ivb file (accessed through the VBA editor) will need to be manually edited on each user's machine. This makes any updates to the "button/s" more difficult.
I would suggest that you use 1 external iLogic rule. This rule should simply fire up a global iLogic form. This form can be edited and shared with your team, without having to change the VBA, the code to implement this is very simple (see below).
SyntaxEditor Code Snippet
This global form can have buttons showing any number of external rules. These external rules can be controlled centrally.
Customising your Button Icon
You can create Bitmap icons for your Macro. You will need 2 sizes, a Large (32x32px) and a Small (16x16px).
The icons will need to be named very specifically in order for them to work. The naming convention is “ModuleName.MacroName.IconSize.bmp”, the size can only be "Small" or "Large". In my example below, the Macro is called "Run_iLogic", my icons are named "Module1.Run_iLogic.Large.bmp" & "Module1.Run_iLogic.Small.bmp".
The icons must be saved to the same location as your Inventor .ivb file, the default location for this file is: "C:\Users\Public\Documents\Autodesk\Inventor 2017" Note that you will need to reboot your system for the icons to become available in Inventor.
For more details on the icons, please see the following blog post:
The VBA Macro that I have used, is based on the following Autodesk Forum post: https://forums.autodesk.com/t5/inventor-forum/vba-macro-ilogic-issue/td-p/4551097