Continue running an ilogic rule once another rule has finished

Continue running an ilogic rule once another rule has finished

sergio_duran
Advocate Advocate
1,965 Views
6 Replies
Message 1 of 7

Continue running an ilogic rule once another rule has finished

sergio_duran
Advocate
Advocate

Hi everyone,

 

I'm running an iLogic rule (let's call it  - First rule) that has a line that activates another open document. When this document is activated, it runs an ilogic rule inside this current document (let's call it - Second rule). Then, it goes back to the first/previous document to continue running the rule (First rule). This is happening but not as expected. The second document is activated it and runs the rule inside (second rule), however, it hasn't finished this rule (second rule) and goes back to the previous document to continue running the first rule.

 

How can I make sure the first rule won't continue running until the second rule has finished?  What is happening is that it initiates the second rule and while this one is running it returns to the first rule. I meant, both are running simultaneously. I want the first one to hold until the second one has finished. Thanks!

0 Likes
1,966 Views
6 Replies
Replies (6)
Message 2 of 7

JaneFan
Autodesk
Autodesk

Hello @sergio_duran

 

It seems like the second rule is triggered by event trigger that it runs automatically once the document being opened, right? In such case, the first rule continues after it runs over the line to open another document, and the second rule is triggered along with the document being opened. So yes, they are simultaneously. 

 

Please try to use RunRule method in the first document, like this: 

1. Remove the related event trigger control from the second document. 

2. In the first rule, add following line after opening the second document: (Replace Part2.ipt with the document name of the second document)

SyntaxEditor Code Snippet

iLogicVb.RunRule("Part2.ipt", "Rule0")

 




Jane Fan
Inventor/Fusion QA Engineer
0 Likes
Message 3 of 7

dgreatice
Collaborator
Collaborator

hi,

 

try using this procedure:

 

Do Until AllDocOpen = True

   'Open Document

   'Make that document active

   'if Document active = true then

          'Run second rule

          'Open Again?

          'If Open Again = Yes then

                  'AllDocOpen = False

          'else

                  'AllDocOpen = True

          'end if

   'else

          'Stop it?

          'AllDocOpen = False

   'end if

  

   

loop

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 4 of 7

lmc.engineering
Advocate
Advocate

Hi,

 

Try this line after the command to run the second rule:

SyntaxEditor Code Snippet

ThisApplication.UserInterfaceManager.DoEvents

Or alternately, I use this to open another document, run any rules, and return to the main document:

SyntaxEditor Code Snippet

Function FileOpenClose(MyFile As String)
		Dim oDoc As AssemblyDocument = ThisApplication.Documents.Open(MyFile)
		auto = iLogicVb.Automation 'Automation for running rules in other document
		auto.RunRule(oDoc, "My Rule Name")
		ThisApplication.UserInterfaceManager.DoEvents
		oDoc.Close(True)
	Return Nothing
End Function
0 Likes
Message 5 of 7

sergio_duran
Advocate
Advocate

Thanks everyone! I'll try your suggestions today and will get back to you asap. Thank you so much once again!

0 Likes
Message 6 of 7

sergio_duran
Advocate
Advocate

Hi JaneFan,

 

This snippet only works when running a rule of a component that is in an assembly.

iLogicVb.RunRule("Part2.ipt", "Rule0")

The parts are not inside an assembly. 

0 Likes
Message 7 of 7

JaneFan
Autodesk
Autodesk

Hey @sergio_duran

 

Oh yes, then we should use iLogicvb.Automation.RunRule() instead. 

SyntaxEditor Code Snippet

Dim oDoc = ThisApplication.Documents.Open(strFileName)
iLogicVb.Automation.RunRule(oDoc, strRuleName)



Jane Fan
Inventor/Fusion QA Engineer
0 Likes