Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Launch iLogic use form with VBA

8 REPLIES 8
Reply
Message 1 of 9
waynehelley
1337 Views, 8 Replies

Launch iLogic use form with VBA

Is this possible??

 

I have tried using VBA to launch an iLogic rule which launches the form but this causes Inventor to crash.

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Tags (1)
8 REPLIES 8
Message 2 of 9
prakasht66
in reply to: waynehelley

Message 3 of 9
waynehelley
in reply to: prakasht66

Thanks for the reply.  I have come accross this threa before though and it only contains information on launching Rules, not Forms.

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Message 4 of 9
skyngu
in reply to: waynehelley

use rules to launch forms
Autodesk Inventor Professional 2019
Message 5 of 9
waynehelley
in reply to: skyngu

That was my first idea but it causes Inventor to crash

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Message 6 of 9
skyngu
in reply to: waynehelley

it doesnt happen on my inventor.
Autodesk Inventor Professional 2019
Message 7 of 9
waynehelley
in reply to: skyngu

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

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Message 8 of 9
waynehelley
in reply to: waynehelley

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

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Message 9 of 9
skyngu
in reply to: waynehelley

it works on my pc.

Autodesk Inventor Professional 2019

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report