Hi, it might have been caused by protection... Try it again in "Default.ivb".
Public Sub RunRule()
RuniLogic ("C:\Path\MyRule.iLogicVb")
End Sub
Public Sub RuniLogic(ByVal RuleName As String)
Dim iLogicAuto As Object
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
If oDoc Is Nothing Then
MsgBox "Missing Inventor Document"
Exit Sub
End If
Set iLogicAuto = GetiLogicAddin(ThisApplication)
If (iLogicAuto Is Nothing) Then Exit Sub
iLogicAuto.RunExternalRule oDoc, RuleName
End Sub
Public Function GetiLogicAddin(oApplication As Inventor.Application) As Object
Set Addins = oApplication.ApplicationAddIns
Dim addIn As ApplicationAddIn
On Error GoTo NotFound
Set addIn = oApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}")
If (addIn Is Nothing) Then Exit Function
addIn.Activate
Set GetiLogicAddin = addIn.Automation
Exit Function
NotFound:
End Function
Btw. Just in case you didn't know, you can use a ribbon button to run this code.
You can set up one like this:
1) Save your ApplicationProject and close "Microsoft Visual Basic For Application" window.
2) In Inventor in opened assembly or part go to "Tools" > "Customize"
3) In left tab expand the dropbox and select "Macros".
4) In right tab expand the dropbox and select "Assembly | Assembly"
5) In left tab select "RunRule".
6) Click on the arrows leading to right.
7) Click "Apply" and "Close".
8) In assembly go to "Assembly" tab and you should see there "User Commands". (On the right side of Ribbon)
9) The button should be there. Use it to run the code.
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods