Inventor Customization

Reply
Mentor
Lance_White
Posts: 154
Registered: ‎06-13-2011
Message 1 of 36 (2,856 Views)
Accepted Solution

Launch External iLogic rule with VBA

2856 Views, 35 Replies
09-26-2011 10:52 AM

Is there someway to launch an external iLogic rule with VBA?. I'd like to add a button to run the iLogic rule.


Lance W.
Inventor Pro 2013 (PDS Ultimate)
Vault Pro 2013
Windows 7 64
Xeon 2.4 Ghz 12GB
Valued Mentor
Posts: 431
Registered: ‎11-24-2003
Message 2 of 36 (2,850 Views)

Re: Launch External iLogic rule with VBA

09-26-2011 02:31 PM in reply to: Lance_White

This has been answered before, but perhaps not exactly this way...

 

--- In a VBA module ---

 

Public Sub LaunchMyRule1   <--- This is what you would tie to a button in a toolbar.

  RuniLogic "MyRule1"

End sub

 

Public Sub LaunchMyRule2   <--- This is what you would tie to a button in a toolbar.

  RuniLogic "MyRule2"

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
  Dim addIns As ApplicationAddIns
  Set addIns = oApplication.ApplicationAddIns

  Dim addIn As ApplicationAddIn
  Dim customAddIn As ApplicationAddIn
  For Each addIn In addIns
    If (addIn.ClassIdString = "{3BDD8D79-2179-4B11-8A5A-257B1C0263AC}") Then
      Set customAddIn = addIn
    Exit For
    End If
  Next

Mentor
Lance_White
Posts: 154
Registered: ‎06-13-2011
Message 3 of 36 (2,837 Views)

Re: Launch External iLogic rule with VBA

09-27-2011 10:50 AM in reply to: Gruff

Thanks.


Lance W.
Inventor Pro 2013 (PDS Ultimate)
Vault Pro 2013
Windows 7 64
Xeon 2.4 Ghz 12GB
Mentor
Lance_White
Posts: 154
Registered: ‎06-13-2011
Message 4 of 36 (2,809 Views)

Re: Launch External iLogic rule with VBA

10-03-2011 09:19 AM in reply to: Gruff

I can't get this to work and I can't figure out what's wrong. I have looked around and the only other code I can find doesn't work either.

 

Nevermind figured it out.

 

Public Sub LaunchMyRule1   <--- This is what you would tie to a button in a toolbar.

  RuniLogic "MyRule1"

End sub

 

Public Sub LaunchMyRule2   <--- This is what you would tie to a button in a toolbar.

  RuniLogic "MyRule2"

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


Lance W.
Inventor Pro 2013 (PDS Ultimate)
Vault Pro 2013
Windows 7 64
Xeon 2.4 Ghz 12GB
Contributor
Posts: 21
Registered: ‎09-01-2009
Message 5 of 36 (2,693 Views)

Re: Launch External iLogic rule with VBA

12-16-2011 04:59 AM in reply to: Lance_White

Thanks a lot !

It works for Inventor 2012 too.

 

I just had to modify first line and add () :

 

 

Public Sub LaunchMyRule1 ()

  RuniLogic "MyRule1"

End sub

 

...

Valued Mentor
Posts: 346
Registered: ‎02-11-2004
Message 6 of 36 (2,619 Views)

Re: Launch External iLogic rule with VBA

01-26-2012 11:48 AM in reply to: Lance_White

Mike,

I've tried using this in a VB6 program. I open up the part first that has the Rule I want to run, but I get an error saying it cannot find the external rule.

The error occurs at iLogicAuto.RunExternalRule oDoc, RuleName.

The RuleName is correct and the part does have a rule with the supplied name. Any suggestions?

Mike Eck
Senior Designer/ CAD Programmer
Howden North America
Using Inventor 2013
Contributor
Posts: 21
Registered: ‎09-01-2009
Message 7 of 36 (2,614 Views)

Re : Launch External iLogic rule with VBA

01-27-2012 05:09 AM in reply to: Lance_White

Hello,

 

This VBA Code is made to launch an external rule only.

You have to link, in Inventor, an external iLogic rune, and not in the file.

Valued Mentor
Posts: 346
Registered: ‎02-11-2004
Message 8 of 36 (2,600 Views)

Re : Launch External iLogic rule with VBA

01-31-2012 03:16 AM in reply to: idubail

Thanks for the reply, but how do I do that?

Mike Eck
Senior Designer/ CAD Programmer
Howden North America
Using Inventor 2013
Valued Mentor
Posts: 346
Registered: ‎02-11-2004
Message 9 of 36 (2,592 Views)

Re : Launch External iLogic rule with VBA

01-31-2012 12:57 PM in reply to: meck

Never mind. I just had to change  

iLogicAuto.RunExternalRule oDoc, RuleName

to

 iLogicAuto.RunRule oDoc, RuleName

Mike Eck
Senior Designer/ CAD Programmer
Howden North America
Using Inventor 2013
Active Contributor
varga_zsolt
Posts: 47
Registered: ‎09-15-2011
Message 10 of 36 (2,387 Views)

Re: Launch External iLogic rule with VBA

05-15-2012 08:14 AM in reply to: Lance_White

I have Inventor pro 2012 but this code doesn't work! I need it can someone help me??????

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube