Cant find sample code

Cant find sample code

rfink
Enthusiast Enthusiast
966 Views
3 Replies
Message 1 of 4

Cant find sample code

rfink
Enthusiast
Enthusiast

Where can I get the below indicated sample code. It is in the Inventor Help Utility, but I cant find it in the suggested directory.

 

 

 

 

A sample VBA macro to access iLogic can be found at the following location:

  • Windows 7 and Windows 8

    Users\Public\Documents\Autodesk\Inventor [version]\Samples\ iLogic Samples\API\iLogicAutoTest.ivb

In the sample code, the GetiLogicAddin function demonstrates how to access the iLogic Automation object in VBA or VB.

0 Likes
Accepted solutions (2)
967 Views
3 Replies
Replies (3)
Message 2 of 4

Owner2229
Advisor
Advisor
Accepted solution

Here you go:

 

 

Public Sub RunMyRule()
   ' Run an external rule
RuniLogicExt "C:\MyPath\MyRule.iLogicVb"
' Run an internal rule
RuniLogicInt "MyRule"
End Sub Private Sub RuniLogicInt(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.RunRule oDoc, RuleName End Sub

Private Sub RuniLogicExt(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 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

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 3 of 4

rfink
Enthusiast
Enthusiast

Mike,

 

Thanks, this is what I was looking for.

 

Do you know if there is any reference material (objects, methods, properties, ect) regarding the iLogic Add In.

 

Regards,

 

Ross

0 Likes
Message 4 of 4

Owner2229
Advisor
Advisor
Accepted solution

You can find a lot of resource materials in:

Inventor > Question mark in top right corner > Help > Help for API

 

Lots of geat blogs are posted here by @ekinsb and @adam.nagy:

Modthemachine

 

You can also just ask here on forum for whatever you want to know.

 

Or tell me what exactly you want to know and I'll try to help you.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods