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: 

Ilogic code to trigger rule in child component

1 REPLY 1
Reply
Message 1 of 2
dave
615 Views, 1 Reply

Ilogic code to trigger rule in child component

Hello,

 

I'm trying to create a rule in ilogic that would search through all child components (looking for both .ipt and .iam file types) looking for an ilogic rule within each child component with a particular name, and running that rule if it is found. Any ideas as to how I could do this?

 

Thanks,

Dave

1 REPLY 1
Message 2 of 2
theo.bot
in reply to: dave

Dave,

 

try this:

 

Sub Main auto = iLogicVb.Automation

' Get the active assembly. Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument

' Get all of the referenced documents. Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments

' Iterate through the list of documents. Dim oRefDoc As Document

For Each oRefDoc In oRefDocs

 Dim ruleName As String  ruleName = "Rule0"  Dim rule As Object  rule = auto.GetRule(oRefDoc, "Rule0")  If (rule Is Nothing) Then  'Call MsgBox("No rule named " & ruleName & " was found in the document.")  Else  MessageBox.Show(rule.Name, oRefdoc.displayname)    Dim i As Integer  i = auto.RunRuleDirect(rule)    End If

Next End Sub

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

Post to forums