Message 1 of 19
Inventor 2022.2 crash on RunExternalRule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
We have a VBA macro button that launches a user form, then on that user form we have a button to run an external ilogic rule that updates our drawing author and date.
After updating to Inventor 2022.2 today, we ran into an issue where if we open a drawing and the first thing we do is hit that button, it crashes Inventor without any warning or error message. If we do anything else such as save or if I open the vba editor first, it works without issue. It also only happens on certain drawing documents.
Here is the code we are using below, the specific line it crashes on is: Call iLogicAuto.RunExternalRule(oDoc, fname & ".txt")
Sub RuniLogicExt(ByVal RuleName As String)
Dim oPath As String
oPath = "[File path on our server here]"
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
MsgBox "iLogicAuto Is Nothing"
Exit Sub
End If
'Determine if file is .txt or .ilogicvb
Set fs = CreateObject("Scripting.FileSystemObject")
Dim fname As String
fname = oPath & RuleName
If fs.FileExists(fname & ".txt") Then
Call iLogicAuto.RunExternalRule(oDoc, fname & ".txt")
ElseIf fs.FileExists(fname & ".iLogicVb") Then
Call iLogicAuto.RunExternalRule(oDoc, fname & ".iLogicVb")
Else
MsgBox ("iLogic rule doesn't exist.")
End If
End Sub
Function GetiLogicAddin(oApplication As Inventor.Application) As Object
Dim addIns As ApplicationAddIns
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