iLogic – Run Rules From a List

@ClintBrown3D Autodesk Inventor blog ilogic run rules from list

I’ve written an iLogic rule that gathers the names of all of the internal rules in a file, and then shows them on an input list box. The user can run any rule on the list by clicking on the rule in the list.

This could be quite useful for users, as it could pop up on an event trigger when a file is opened, or saved.

Here is a GIF of the rule in action.


Unofficial Inventor blog ilogic run rules from list
click me for a high res version


Below is the iLogic code.

'iLogic Rule by @ClintBrown3D
'Originally posted here:

On Error GoTo ClintsErrorTrap
doc = ThisApplication.ActiveDocument
Logic = iLogicVb.Automation
Dim ClintBrown3D As New ArrayList
Dim ListOrules As System.Collections.IEnumerable = Logic.Rules(doc)

For Each oRule As iLogicRule In ListOrules
	iLogicRules = InputListBox("Select A rule to run" , ClintBrown3D, iLogicRules, Title := "Unofficial Inventor", ListName := "Below is a list of all internal rules in this document")

ClintsErrorTrap :
MessageBox.Show("Nothing seleted!", "@ClintBrown3D", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)



I’ve written some code to extract your external rules. You just need to include the path to your current external rules directory. This is easy to find, just right click on your external rules folder and select “Open Folder”, then copy the path to your clipboard and paste it into “SpecifiedDirectory” in the code.

SpecifiedDirectory = "C:\YourPath"

@ClintBrown3D Autodesk Inventor 55

'iLogic Rule by @ClintBrown3D
'Originally posted here:

Dim ClintBrown3D As New ArrayList
SpecifiedDirectory = "C:\Users\Clint\iLogic- External rules" 'SPECIFY YOUR EXTERNAL RULE FOLDER HERE!
Dim oDirectory As New IO.DirectoryInfo(SpecifiedDirectory)
Dim GoGetFilesA As IO.FileInfo() = oDirectory.GetFiles("*.txt") 'filter by type
Dim GoGetFilesB As IO.FileInfo() = oDirectory.GetFiles("*.iLogicVb")
Dim oFiles As IO.FileInfo

For Each oFiles In GoGetFilesA : ClintBrown3D.Add(oFiles.Name) : Next
For Each oFiles In GoGetFilesB : ClintBrown3D.Add(oFiles.Name) : Next
ClintBrown3D.Sort 'This puts them in Alphabetical order

FilesInFolder = InputListBox("Choose a File", ClintBrown3D, FilesInFolder, Title := "Unofficial Inventor", ListName := "Here are the files")
Rulename = FilesInFolder
If FilesInFolder = "" Then : Return : End If

This version of the code was tested with Inventor 2020. The rule only works with internal rules.

Please note that I cannot offer any additional support, this blog post is offered as-is, and is aimed at the more advanced user.

As always, please test all iLogic code extensively on non-production files. Do not use any code in a production environment until YOU have thoroughly tested it and have verified that it works as expected. Always back up any data before running any experimental code. You are ultimately responsible for any iLogic code that you run, so make sure you test it thoroughly!

Comments are closed.

Create a website or blog at

Up ↑

%d bloggers like this: