Is this possible??
I have tried using VBA to launch an iLogic rule which launches the form but this causes Inventor to crash.
Hi,
I think this link may be useful for you.http://forums.autodesk.com/t5/Inventor-Customization/Launch-External-iLogic-rule-with-VBA/m-p/317061...
Thanks for the reply. I have come accross this threa before though and it only contains information on launching Rules, not Forms.
That was my first idea but it causes Inventor to crash
I can launch an ilogic rule from VBA fine but when the ilogic rule contains code to launch a form, it crashes Inventor. I'm using 2013 so maybe this problem will be resolved when we get around to upgrading
If you wanted to try my VBA code, it is as follows. The idea is that Inventor will attempt to launch the rule 'MCC Tier Configurator Form' which launches the form. On success, Exit Sub. On Error, continue with the code which will open a specified document as a template. Inside this document is an ilogic event trigger which will launch the form.
Basically the User will get the form in either scenario. A new document will only be created if needed.
Public Sub MCC_Tier_Configurator()
Dim iLogicAuto As Object
Set iLogicAuto = GetiLogicAddin(ThisApplication)
If (iLogicAuto Is Nothing) Then Exit Sub
Dim curDoc As Document
Set curDoc = ThisApplication.ActiveDocument
On Error GoTo RuleDoesNotExist:
'Launching "MCC Tier Configurator Form" crashes Inventor so is commented for now
iLogicAuto.RunRule curDoc, "MCC Tier Configurator Form"
Exit Sub
RuleDoesNotExist:
Dim oProjectMgr As DesignProjectManager
Set oProjectMgr = ThisApplication.DesignProjectManager
Dim oProject As DesignProject
Set oProject = oProjectMgr.ActiveDesignProject
Dim oDoc As AssemblyDocument
On Error Resume Next
tryagain:
If Dir("C:\Work\Designs\Templates\2013\Inventor Templates\Metric\UK iLogic Configurators\MCC Tier.iam") = "" Then
i = MsgBox("The MCC Tier Configurator Template does not exist locally. Please download the file, C:\Work\Designs\Templates\2013\Inventor Templates\Metric\UK iLogic Configurators\MCC Tier.iam, from Vault.", vbRetryCancel + 48, "MCC Tier Configurator")
If (i = vbRetry) Then
GoTo tryagain
End If
Else
Set oDoc = ThisApplication.Documents.Add(kAssemblyDocumentObject, "C:\Work\Designs\Templates\2013\Inventor Templates\Metric\UK iLogic Configurators\MCC Tier.iam", True)
End If
End Sub
Function GetiLogicAddin(oApplication As Inventor.Application) As Object
Dim addIns 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