Here is an example of an Excel VBA macro that will run a local iLogic rule within an Inventor document. It assumes that Inventor is already running, and that the target document (with the rule in it) is open and active. You will most likely have to change the name of the iLogic rule I am specifying within. You can get the document however you want, but to keep this example simple, I'm just getting the 'active' one, for now. Also, I don't know if you need to 'send' anything to that iLogic rule or not, but if you do need to, you can use one of the other variations of the RunRule type methods (I left a few commented out near the end, for convenience). Another important thing to notice is how I'm getting the Inventor application. You can't simply use the term 'ThisApplication' here, because that would be trying to get the Excel application, instead of the Inventor application. If Inventor is not running, you could try using CreateObject() instead, or use a Function that tries both ways, then returns the appropriate application object.
Here is the VBA code for it:
Sub RunInventorLocaliLogicRule()
Dim oInv As Inventor.Application
Set oInv = GetObject(, "Inventor.Application")
'get the iLogic Add-in, and its Automation object
'so we can use the 'RunRule' type methods defined within it
Dim oAddin As Inventor.ApplicationAddIn
Dim iLogic As Inventor.ApplicationAddIn
For Each oAddin In oInv.ApplicationAddIns
If VBA.Strings.InStr(oAddin.DisplayName, "iLogic") > 0 Then
Set iLogic = oAddin
Exit For
End If
Next
If iLogic Is Nothing Then Exit Sub
If Not iLogic.Activated Then iLogic.Activate
Dim oAuto As Object
Set oAuto = iLogic.Automation
'specify target document for external rule to effect
Dim oDoc As Inventor.Document
Set oDoc = oInv.ActiveDocument
'Set oDoc = oInv.Documents.Open("C:\Temp\MyAssembly.iam", True) 'False = open invisibly
'specify the name of the rule
Dim oRuleName As String
oRuleName = "LocalRuleName"
Call oAuto.RunRule(oDoc, oRuleName)
'Call oAuto.RunRuleWithArguments(oDoc, oRuleName, oRuleArguments)
'Call oAuto.RunExternalRule(oDoc, oRuleName)
'To send data to the iLogic rule, first create a NameValueMap,
'create some name/value pairs within it,
'then supply that in place of the 'Arguments' input variable in the RunRuleWithArguments() method
'Dim oRuleArguments As Inventor.NameValueMap
'Call oRuleArguments.Add("TargetDocument", oDoc)
'Call oAuto.RunExternalRuleWithArguments(oDoc, oRuleName, oRuleArguments)
'the iLogic rule will need to be set-up to retrieve that NameValueMap using the RuleArguments interface.
'once the iLogic rule has retrieved it, it can get/set values or pairs within it
'once the iLogic rule finishes, it will return control to this VBA macro,
'then the macro can simply retrieve any resulting values from the NameValueMap it created earlier
End Sub
P.S.: Be aware that if the rule contains any pop-up dialogs, like MessageBox.Show(), or MsgBox(), or similar that you may need to interact with, Inventor may not currently have top system focus, so the pop-up dialog might possibly be hidden behind an application window or something like that. If that happens, it may appear like Excel is taking a really long time to run the macro, but it may in fact be waiting on you to interact with the dialog from the rule, before it will continue.
Wesley Crihfield

(Not an Autodesk Employee)