by Luke Davenport
Your iLogic rules are working well, but you need to make them run faster.
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
' 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.