I'm sure there are numerous sources for similar code here on the forum, but here is a fairly simple one I was using for a while. I had an external iLogic rule that would export an IDW (drawing document) to a PDF. Then I used this VBA macro to run that rule, so that I could place the button for that macro onto my ribbon, for a 1-click run solution.
Here's the code:
First thing it does is get Inventor's iLogic Addin. There is a more direct way to do this with fewer lines, by specifying it by its ID string, but I usually preffered to avoid doing it that way, because it uses a long, unreadable string of nonsense, versus just searching for it by its name.
It then defines the name of the external rule file. Then identifies the document you want that external iLogic rule to affect (work on). Then uses the iLogic Addin to run the rule.
Public Sub Export_IDW_to_PDF()
Dim oAddIns As ApplicationAddIns
Dim oAddIn As ApplicationAddIn
Set oAddIns = ThisApplication.ApplicationAddIns
For Each oAddIn In oAddIns
If InStr(oAddIn.DisplayName, "iLogic") > 0 Then
oAddIn.Activate
Dim iLogicAuto As Object
Set iLogicAuto = oAddIn.Automation
Exit For
End If
Next
'Debug.Print oAddIn.DisplayName
Dim oXRuleName As String
oXRuleName = "Export IDW to PDF"
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
If oDoc Is Nothing Then
MsgBox "Missing Inventor Document"
Exit Sub
End If
iLogicAuto.RunExternalRule oDoc, oXRuleName
End Sub
Wesley Crihfield

(Not an Autodesk Employee)