iLogic rule running order and delay

iLogic rule running order and delay

charles4L34S
Contributor Contributor
794 Views
3 Replies
Message 1 of 4

iLogic rule running order and delay

charles4L34S
Contributor
Contributor

~ Solved before I even hit post, in a last ditch effort I checked one more thread~

It appears that using the iLogicVb.Automation.RunRule allows the prior rule to finish before moving on, simply adding this to the end of my code that generates the drawing from the assembly worked instantly (once I removed all of the messy debug steps)

Why am I posting this regardless? I searched for days trying to find a solution, and nothing matched the issue I was having, be it caused by my terrible coding or poor knowledge, I don't want some other unlucky soul to face the same issue.

 

Hi, 

I've been tackling a problem in my iLogic sequence for several weeks now to no avail...

I have a set of rules that from start to finish create an assembly and create a drawing from the assembly with dimensions etc.

I have a rule in my assembly that creates the drawing and places views, then, in my drawing I have a rule to add dimensions to the views.

The problem comes when trying to automatically run the drawing rule, if I use the "on new document" iTrigger, it runs the rule but doesn't wait until the assembly rule that places the views finishes, instead it will error out as no views exist yet. Once the error is handled, the dimension rule exits, which then allows the assembly rule to exit at which point inventor places the views on the sheet. 

 

Currently, my workaround is to show a form (which I would need to show anyway) using the "on new document" iTrigger in the drawing. The form is shown, the rule exits and then the assembly rule exits and all is well, but this leaves the user to manually run the dimension rule. It works, the user is "tricked" into waiting a second or two before running the rule but I'd like a more permanent solution.

 

Other things I have tried

  • Adding a sleep to the dimension rule - all this does it wait while the assembly rule is paused in the background, after the sleep it runs but because the assembly rule hasn't finished it errors out
  • Using the assembly rule to call an external rule - the external rule cannot run any of the drawing rules and it is called before the assembly rule is finished, so the new drawing isn't loaded yet

It seems like my main issue is that I can't exit the drawing creation rule before running other rules in the newly created drawing, or that there is no trigger to wait until the views are present and the rule is finished before automatically running another rule.

 

0 Likes
795 Views
3 Replies
Replies (3)
Message 2 of 4

A.Acheson
Mentor
Mentor

Hi @charles4L34S 

 

If I understand your requested functionality correctedly you could solve this using a do loop with command manager and do events and check if the view updating is complete. This will stop the code advancing untill all views are generated. I found this using a post on the forum and if I find the link I will dig it out for you. 

Syntax

DrawingView.IsUpdateComplete() As Boolean

 

The alternative is to run the rule by code after the code generates the views. I'd rather use that than event triggers. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 4

charles4L34S
Contributor
Contributor

Hi @A.Acheson,

 

I will look into this with future iLogic, I think however with the way I was trying to do this the rule to create the drawing was waiting for other rules to finish prior to placing the drawing views, so anything that relied on the iTriggers in the drawing environment was holding up the view placement.

 

In the end as mentioned, I got the "RunRule" working from the context of the assembly drawing which allowed all other operations to finish before running the next rule

 

Thanks,

0 Likes
Message 4 of 4

A.Acheson
Mentor
Mentor

In case it comes in handy here is that method for pausing rule while views update.

Dim oDrawing As DrawingDocument = ThisApplication.ActiveDocument	
For Each oView As DrawingView In oDrawing.ActiveSheet.DrawingViews
	oDrawing.Update
	Do While oView.IsUpdateComplete = False
	  Call ThisApplication.UserInterfaceManager.DoEvents
	Loop
Next

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan