How to run an extarnal Ilogic run using VBA Marco

How to run an extarnal Ilogic run using VBA Marco

Darkforce_the_ilogic_guy
Advisor Advisor
358 Views
2 Replies
Message 1 of 3

How to run an extarnal Ilogic run using VBA Marco

Darkforce_the_ilogic_guy
Advisor
Advisor

I want to make a bottom/Marco that run an Extarnal ilogic rule call SurfaceColour.

 

I have try some stuff found of the web about it ... but it does not seens to work.

 

how do I do it ?

0 Likes
359 Views
2 Replies
Replies (2)
Message 2 of 3

Sergio.D.Suárez
Mentor
Mentor

Hi,  for a while I have had this macro that worked very well, stop using it for the work that requires go for each PC and accommodate all the custom tools, I get used to using external rules.
In red is the name of the external rule that you must put in quotation marks,
You must specify a macro name, I use for example RuleA and Rule B, you can create many macros and then add the macro to a custom button from customize user command

 

 

Public Sub RuleA() ' <--- This is what you would tie to a button in a toolbar.
RuniLogic "RulenameA"
End Sub
Public Sub RuleB() '<--- This is what you would tie to a button in a toolbar.
RuniLogic "RulenameB"
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 "Please Open 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 hope it helps to solve your problem, greetings


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 3 of 3

chandra.shekar.g
Autodesk Support
Autodesk Support

@Darkforce_the_ilogic_guy,

 

Try below VBA code to run external iLogic rule.

Public Sub Internal_iLogic()

    Dim addIn As ApplicationAddIn
    Dim addIns As ApplicationAddIns
    Set addIns = ThisApplication.ApplicationAddIns
        For Each addIn In addIns
            If InStr(addIn.DisplayName, "iLogic") > 0 Then
                            addIn.Activate
                Dim iLogicAuto As Object
                Set iLogicAuto = addIn.Automation
                Exit For
            End If
        Next
    Debug.Print addIn.DisplayName
     
     
    Dim RuleName1 As String
    EXTERNALrule = "3D PDF"
    
    Dim RuleName2 As String
    INTERNALrule = "Rule2"
     
      Dim oDoc As Document
     
      Set oDoc = ThisApplication.ActiveDocument
      If oDoc Is Nothing Then
        MsgBox "Missing Inventor Document"
        Exit Sub
      End If
     
    'iLogicAuto.RunRule oDoc, INTERNALrule 'for internal rule
    iLogicAuto.RunExternalRule oDoc, EXTERNALrule 'for external rule

End Sub

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes