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: 

Adding iLogic Rule Using the API

6 REPLIES 6
Reply
Message 1 of 7
MegaJerk
2514 Views, 6 Replies

Adding iLogic Rule Using the API

I've caught glimpses of how to do this (For instance, this plugin (Inventor LinkParameters)  http://labs.autodesk.com/utilities/ADN_plugins/) , but honestly feel stumped when trying to actually find information on any documentation of how to get from point A to point B. I can't seem to find anything about ilogic automation / rule creation / ilogic in general, in the object browser at all. 

I know code like this exists

Option Explicit

Sub RuniLogicRule()

Dim iLogicAuto As Object
Set iLogicAuto = GetiLogicAddin(ThisApplication)
If (iLogicAuto Is Nothing) Then Exit Sub

Dim doc As Document
Set doc = ThisApplication.ActiveDocument

Dim ruleName As String
ruleName = "Rule0"
Dim rule As Object
Set rule = iLogicAuto.GetRule(doc, "Rule0")
If (rule Is Nothing) Then
  Call MsgBox("No rule named " & ruleName & " was found in the document.")
  Exit Sub
End If

Dim i As Integer
i = iLogicAuto.RunRuleDirect(rule)

End Sub


Function GetiLogicAddin(oApplication As Inventor.Application) As Object
Dim addIns As ApplicationAddIns
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

 
(and even fixed the error it gave me due to the original code leaving something out) , but have no idea where any info on the GetRule method is. 

If anyone could help to point me in the correct direction for documentation or could provide an example even, I would be most grateful, as I certainly failing to see a major piece of the puzzle.

 

 



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
6 REPLIES 6
Message 2 of 7
MjDeck
in reply to: MegaJerk

There is some documentation available.  If you open the LinkParameters solution in Visual Studio, you can find it on the Object Browser under Autodesk.iLogic.Interfaces.  Look at the IiLogicAutomation interface.  This has an AddRule function.

 This documentation is found in an XML file: Autodesk.iLogic.Interfaces.xml.  On Inventor 2011, this file is found in
C:\Program Files\Autodesk\Inventor 2011\Bin\iLogicBin

On 2012, it is found in
C:\Program Files\Autodesk\Inventor 2012\Bin

 We should be able to add more documentation and produce a .chm file in a future version.


Mike Deck
Software Developer
Autodesk, Inc.

Message 3 of 7
MegaJerk
in reply to: MjDeck

Is there a way to add a reference to this file in the VBA editor (that comes with Inventor)? Any time that I try to add it in the object browser it gives me the error of : Can’t add a reference to the specified file.

I have Visual Studios at home, but not here at work, which is why I am curious about adding it to the VBA editor if possible.

Thank you!    



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 4 of 7
MjDeck
in reply to: MegaJerk

You can't add it in VBA because it only exposes .NET interfaces, and not COM.
You can download a free version of Visual Studio (Visual Basic Express) at
http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-basic-express


Mike Deck
Software Developer
Autodesk, Inc.

Message 5 of 7
Walliguy
in reply to: MjDeck

@MjDeck thank you for this reference, it was really helpful!

Message 6 of 7
MjDeck
in reply to: MegaJerk

Hi @Walliguy - do you mean Autodesk.iLogic.Interfaces.xml?
For recent releases of Inventor, all the information in there is now available online. Here's the 2024 version.


Mike Deck
Software Developer
Autodesk, Inc.

Message 7 of 7
Walliguy
in reply to: MjDeck

Hey @MjDeck,

Yes I was referring the XML file. Thanks for the link, I have always navigated my way into the help documentation through Inventor.

 

Thanks again,

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report