Inventor 2015 - iLogic Timer – How Long Does My Rule Take To Run?

Zen Admin
Zen Admin

by Luke Davenport

  

Issue:

Your iLogic rules are working well, but you need to make them run faster.

 

Solution:

Use some simple 'stopwatch' code to measure how long your code takes to run – this'll help you gauge the success of your code optimisation.

 
Dim StartTime As DateTime
Dim ElapsedTime As TimeSpan
 
' Start the timer from this point
StartTime = Now
 
' Add your actual iLogic code in here – (this is a dummy calculation to consume some time)
For i = 1 To 10000000
    Dummycalculation = Dummycalculation + i
Next
 
' Stop the timer at this point, and display the elapsed time to the user
ElapsedTime = Now().Subtract(StartTime)
MessageBox.Show("Operation took " & ElapsedTime.TotalSeconds & " Seconds", "Cadline iLogic")








And there's your simple code timer. Job done.

 

One little hint – if you do happen to have an iLogic rule that is taking a long time to run, consider placing a stopwatch like this on any loops within your code to measure how long each iteration is taking, then try making a few adjustments to the loop code (make sure you don't put a message box in a loop though, unless you want to drown in message boxes!).  Making your loops more efficient will often be the key to faster iLogic rules.

 

What's that? You want to know how to actually optimise your code? Not this time I'm afraid!

 

As always – give us a call at Cadline to help you reach your automation and Logic goals in Inventor.

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.