iLogic – File Open Timer

I thought I’d share an update to an old timer that I wrote a few years back, it was designed to show the difference between opening a file saved on a network drive, versus one stored locally. The original idea, being that using Vault will give a user a much better experience when opening large datasets. But it’s also useful in other cases, for example for checking time savings on large assemblies with their constraints suppressed.

I’ve tweaked my original idea slightly, so that it uses the same “File Open” dialogue that I shared in last week’s post.

I have not commented the code, as my previous post does this quite well. The timing element is very simple. The timer gets the current time and firstly converts the minutes to seconds (e.g. 10:01:02 is 01×60 = 60 seconds). Then it adds the seconds to that calculation to create a current time called “Timer1”.

Timer1 = (Now.Minute*60)+(Now.Second)

After the file has been opened, an identical second time calculation is performed to get “Timer2”, and then the elapsed time is calculated by subtracting “Timer1” from “Timer2”.

Timer2 = (Now.Minute*60)+(Now.Second)
elapsedtime = Timer2 - Timer1

The animated GIF shows the code in action, note that in one of the examples, the file shows a 0 second open time, I believe that this is because the file was already loaded into memory. I could include “Now.Millisecond” to the timer, but I think that this is unnecessary.

There are a couple of small notes to add to this. Firstly, because I am running this as an iLogic rule, I need to have a file open to run it (which is why I start with a blank part file). Secondly, you may have noticed the button that I click on to run the rule, this is courtesy of the FREE “Button Constructor” app that allows you to run iLogic rules from your ribbon.

Here’s the code:

'iLogic code by @ClintBrown3D, https://clintbrown.co.uk/ilogic---file-open-timer
oDoc = ThisDoc.Document
Dim oFileDlg As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)

oFileDlg.Filter = "Inventor Files |*.dwg; *.idw; *.ipt; *.iam"
oFileDlg.InitialDirectory = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath
oFileDlg.DialogTitle = "Unofficial Inventor"
oFileDlg.ShowOpen()
ClintBrown3D = oFileDlg.FileName
If ClintBrown3D = "" Then : Return : End If

Timer1 = (Now.Minute*60)+(Now.Second)

ThisDoc.Launch(ClintBrown3D)

Timer2 = (Now.Minute*60)+(Now.Second)
elapsedtime = Timer2 - Timer1
MessageBox.Show("This File took " & elapsedtime & " seconds to open", "@ClintBrown3D")

Comments are closed.

Create a website or blog at WordPress.com

Up ↑