File time counter

File time counter

kresh.bell
Collaborator Collaborator
673 Views
5 Replies
Message 1 of 6

File time counter

kresh.bell
Collaborator
Collaborator

Hi,

is it possible to create a Logic which, when started, would show how much time in total (I mean closing and reopening) was spent working on that file?

0 Likes
674 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor

Here is a simple Stopwatch example.  It uses the System.Diagnostics.Stopwatch Class.  It is often used to gauge elapsed time differences between different versions of the same code/application for efficiency purposes.  Maybe you can use this object to achieve your goal.

Dim oTimer As New Stopwatch
oTimer.Start
'Do some stuff here
Dim i As Long
Dim oCode As Long
'simply gives it something to do a bunch of times for the example
'should only take a few seconds
For i = 1 To 1000000
	oCode = ThisApplication.Locale
Next
oTimer.Stop
'This one is more specific (shows 3 decimal places after seconds)
MsgBox("Elapsed time = " & oTimer.ElapsedMilliseconds / 1000 & " seconds", vbOKOnly, " ")
'or this one doesn't have any decimal places
'MsgBox("Elapsed time = " & oTimer.Elapsed.Seconds & " seconds",vbOKOnly," ") 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.

If you have time, please... Vote For My IDEAS 💡and Explore My CONTRIBUTIONS

Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6

WCrihfield
Mentor
Mentor

Here is another simple 'Timer' example rule, which uses a different method.

 

Dim oStart, oFinish, oTotal As Double
MsgBox("Click 'OK' to start the timer.",,"")
oStart = Microsoft.VisualBasic.DateAndTime.Timer
MsgBox("Click 'STOP' to stop the timer.",,"")
oFinish = Microsoft.VisualBasic.DateAndTime.Timer
oTotal = oFinish - oStart
MsgBox(oTotal & " seconds have elapsed.",,"")

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 6

dutt.thakar
Collaborator
Collaborator

@kresh.bell 

 

Check out the below link on @Anonymous Unofficial Inventor blog, which is explaining the same thing you are trying to achieve.

 

https://clintbrown.co.uk/2020/12/12/ilogic-file-open-timer/

 

Hope this will be helpful.

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
0 Likes
Message 5 of 6

kresh.bell
Collaborator
Collaborator

Hi,

thanks but i didn't mean that. I work on multiple projects at the same time. I would like to know how much time I have worked on a project without having to write down the time on paper

0 Likes
Message 6 of 6

WCrihfield
Mentor
Mentor

OK.  I think I understand now.  I'm thinking you might need something like an Addon or a standalone app to accomplish that, instead of iLogic rules or VBA macros.  You need something that will automatically activate in the background, no mater what documents you may be opening, working with, or closing, and stay active in the background until all documents (or the application) are closed, then it will automatically stop and write elapsed time data to a static file on your hard drive, which can later be accessed and multiple session times summed up to a total project time.  Sounds like it may be doable though.  Unfortunately I may not be a lot of help there, because our company doesn't currently allow any employees Admin rights on their own PC's, so creating Addins is not possible for me at this time.

  The closest non-addin solution I can think of right now would be something like the following:

An external iLogic rule that is set-up within your Event Triggers dialog, under the "All Documents" tab, under "New Document", "After Open Document", and "Close Document", so it will be fired by all these events.  Then at the top of your rule, to avoid unnecessary runs/processes, have some code that checks (for when Open has triggered it) if any other documents are already open.  If no other docs are open, write this event start time to file.  If other docs are already open, your still working, so ignore it and exit the rule.  Also, at the top as a check (for when Close has triggered it), see if any docs are left open.  If no docs are open, it just closed the last one, so write this finish time to file.  Then later in the rule, you can have some code to retrieve and sum up (calculate) all current entries within that data file (likely Excel file), and offer an option to display it.  At least that's what's rolling around in my head.  Does that make sense to you?

I hope this helps in some way.

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes