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: 

Check if external ilogic-rule is loaded

4 REPLIES 4
Reply
Message 1 of 5
GeorgK
517 Views, 4 Replies

Check if external ilogic-rule is loaded

Hello together,

 

how could I check if an external iLogic rule is loaded (added)? Or how could I load (add) it?

 

Thank you very much

 

Georg

4 REPLIES 4
Message 2 of 5
philippe.leefsma
in reply to: GeorgK

I'm not sure there is an easy way. You could give a try at the IiLogicAutomation, this is a COM component available from "C:\Program Files\Autodesk\Inventor %version%\Bin\Autodesk.iLogic.Interfaces.dll"

 

It exposes methods to enumerate rules that are in a document, but I don't see a way to check if an external rule is loaded. Here is a pic of what you can see in the Visual Studio object browser, I'm not sure this is documented anywhere:

 

ilogic.png

 

I could'nt reference the dll from VBA, but invoking the code with late binding works:

 

Sub getILogic()

    Dim iLogic As ApplicationAddIn
    Set iLogic = ThisApplication.ApplicationAddIns.ItemById("{3BDD8D79-2179-4B11-8A5A-257B1C0263AC}")

    iLogic.activate
    
    Dim iLogicAutomation As Variant
    Set iLogicAutomation = iLogic.Automation
    
    Dim rules As Variant
    Set rules = iLogicAutomation.rules( _
        ThisApplication.ActiveDocument)

    Dim rule As Variant
    For Each rule In rules
        Debug.Print "Rule: " + rule.Name
    Next
    
End Sub

 Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 5
rjay75
in reply to: GeorgK

The only way I've found to determine if an External rule is to assume it is and to try running it with an try/catch block or error handling. If it fails then it means it not loaded or cannot be found.

 

Also if you run it from code it's possible to supply the full file name of the rule instead of just the name. The rule doesn't have to be added to the browser in order to run. If you use the file name you can just check to see if the file exists.

Message 4 of 5
philippe.leefsma
in reply to: rjay75

Here is the feedback I received from the development team:

 

 No, there is no API call to check if an external iLogic rule is loaded in the iLogic browser. And there is no call to load it into the browser.

 

We didn’t think that these calls would be required, because you don’t have to load a rule into the browser in order to run it.

 

When you use the iLogicVb.RunExternalRule function, it searches for the rule file in:

 

-          The document directory

-          The current project Workspace directory

-          The global external rule directories specific in Tools > Options > iLogic Configurations

 

Note that the search doesn’t descend into subdirectories.

 

You can’t load the Autodesk.iLogic.Interfaces.dll into VBA references because it is not a true COM API. It is a .NET API made visible through COM.

 

I hope that helps,

Philippe.

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 5 of 5
GeorgK
in reply to: philippe.leefsma

Thank you for the answer.

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

Post to forums  

Autodesk Design & Make Report