Macro Runs - But not when Hot Key is used
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So, I used the code found here with super minor modifications: https://forums.autodesk.com/t5/inventor-customization/inventor-pro-2014-ilogic-assign-a-keystroke-to... and the method described in message 4 of 4 to set up my hotkey and create the "macro".
My iLogic Code works correctly (changes dim styles) and the macro runs correctly when I run it thru the macro menu under the Tools Tab.
When I initially run the macro, I get this error
But if I manually run the rule once, I don't get the error when I run the macro.
Someone suggested changing: iLogicAuto.RunExternalRule oDoc, RuleName to iLogicAuto.RunRule oDoc, RuleName
but that had no effect.
Once I do get it working, I have an assigned Hot Key and it works as well.
This is the Module in my Main VB Project:
Public Sub HoleDimStyle() '<--- This is what you would tie to a button in a toolbar.
RuniLogic "HoleDimeStyle" 'there was a type that is why it is Dime and not Dim...
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
Function GetiLogicAddin(oApplication As Inventor.Application) As Object
Set addIns = oApplication.ApplicationAddIns
'Find the add-in you are looking for
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
I have verified multiple times, that external iLogicRule is loading correctly..i.e. it "exists" in the document before I run the macro.