This can be achieved by accessing the iLogic automation object from the iLogic addin. (Any addin internals can be manipulated as long as it has exposed itself in it's addin automation section). I personally use it to call external iLogic rules from my addin since its easier to maintain the rules. You can also make use of "iLogicVB.Automation.RulesOnEventsEnabled" or other ilogic features like delayed running mode. Note that this is similar to accessing iLogic from VBA.
Firstly, the iLogic Addin must be installed on any machine that your addin is used (assuming this is already done...).
Add the
Autodesk.iLogic.Automation.dll
to your IDE project references. This DLL should be located in the bin folder of your Inventor install (same folder as Inventor.exe)
Then its a matter of accessing the addin. You can grab it via client ID, or loop search it. I prefer loop search, but it is slower.
Imports Inventor
Imports Autodesk.iLogic.Automation
Imports System.Linq 'exposes ienumerable concat function
''' Optional global variable somewhere
Public Shared iLogic As iLogicAutomation
''' In a method somewhere ("g_inventorApplication" is your application object)
''' Using loop '''
For Each addin As ApplicationAddIn In g_inventorApplication.ApplicationAddIns
'Debug.Print(addin.ClientId)
If addin.DisplayName = "iLogic" Then
iLogic = addin.Automation
' you can activate/deactivate the addin and some other functions with the addin object
' Add paths to existing
'Dim ilogicExtDirs As String() = iLogic.FileOptions.ExternalRuleDirectories.Concat({"C:\Folder 1\", "C:\Folder 2\"}).ToArray
' Start fresh
'Dim ilogicExtDirs As String() = {"C:\Folder 1\", "C:\Folder 2\"}
iLogic.FileOptions.ExternalRuleDirectories = ilogicExtDirs
Exit For
End If
Next
'''' Get addin via client ID '''
iLogic = g_inventorApplication.ApplicationAddIns.ItemById("{3BDD8D79-2179-4B11-8A5A-257B1C0263AC}").Automation
' Add paths to existing
'Dim ilogicExtDirs As String() = iLogic.FileOptions.ExternalRuleDirectories.Concat({"C:\Folder 1\", "C:\Folder 2\"}).ToArray
' Start fresh
'Dim ilogicExtDirs As String() = {"C:\Folder 1\", "C:\Folder 2\"}
iLogic.FileOptions.ExternalRuleDirectories = ilogicExtDirs
The only caveat i can think of is that the iLogic addin is potentially not enabled/loaded when your addin is loaded, this can be checked by looking at the addin.Activated property, or in my case, I don't fully load my addin until inventor fires it's onReady event (defeats the purpose of onReady, but oh well). Since you want to run this via a ribbon button, you might not have any issue since ribbon buttons cannot be clicked until onReady is fired anyways.
Hope this helps!