Run External iLogic rule from vb.net Inventor Addin Error

Run External iLogic rule from vb.net Inventor Addin Error

Anonymous
Not applicable
1,253 Views
2 Replies
Message 1 of 3

Run External iLogic rule from vb.net Inventor Addin Error

Anonymous
Not applicable

I am creating a custom Addin for Inventor 2019 coding in Visual Basic 2017, and I am trying to create a button that runs an external iLogic rule. I have looked through previous forum posts and gotten code that should work from there, but the line "iLogicAuto.RunExternalRule(oDoc, RuleName)" (highlighted in red below) does not work as it is supposed to. I have verified that the GetiLogicAddin function is correctly getting the iLogic Addin.

 

Similar versions of this question have been posted several times on the forum, but the verified answers are not working for me. Some of the forum posts I have looked into are here:

https://forums.autodesk.com/t5/inventor-customization/launch-external-ilogic-rule-with-vba/td-p/3170...

https://forums.autodesk.com/t5/inventor-customization/launch-external-ilogic-rule-with-vba/m-p/31708...

 

Here is my code:

 

Private Sub m_balloonUpdateButton_OnExecute(Context As NameValueMap) Handles m_balloonUpdateButton.OnExecute
RuniLogic("BalloonUpdateStyles")
End Sub

 

Public Sub RuniLogic(ByVal RuleName As String)
Dim iLogicAuto As Object
Dim oDoc As Document
oDoc = g_inventorApplication.ActiveDocument


If oDoc Is Nothing Then
MsgBox("Missing Inventor Document")
Exit Sub
End If

 

iLogicAuto = GetiLogicAddin(g_inventorApplication)


If iLogicAuto Is Nothing Then Exit Sub


iLogicAuto.RunExternalRule(oDoc, RuleName)


End Sub

 

Function GetiLogicAddin(oApplication As Inventor.Application) As Object
Dim addIns As ApplicationAddIns
addIns = oApplication.ApplicationAddIns
Dim addIn As ApplicationAddIn
On Error GoTo - 1


addIn = oApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}")

If (addIn Is Nothing) Then Exit Function
addIn.Activate()

 

GetiLogicAddin = addIn.Automation

 

Exit Function
End Function

0 Likes
Accepted solutions (1)
1,254 Views
2 Replies
Replies (2)
Message 2 of 3

MjDeck
Autodesk
Autodesk
Accepted solution

Is the external rule file stored in a directory that is listed in External Rules Directories in the dialog brought up by the the Tools > Options > iLogic Configuration command?
Can you run the rule manually from the iLogic browser?
Does the rule throw an error when you run it with the API?


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 3 of 3

Anonymous
Not applicable

Thank you! The rule I was trying to run was in a sub-folder of the folder listed in the iLogic Configuration window. Adding the sub-folder to the list of external rules directories solved the problem!

0 Likes