View Single Post
  #4  
Old 07-10-2013, 09:47 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
For high resolution timing values, you should use either viz.tick() or time.clock(). These functions will provide the number of seconds since the application started. If you need a high resolution representation of the actual time, then you can capture the current time at the beginning of your script and then add on the high resolution seconds to it at runtime. Here is an example:
Code:
import viz
import vizact
import datetime

viz.go()

# Get starting time and tick
startTime = datetime.datetime.now()
startTick = viz.tick()

def LogTime():

	# Add elapsed seconds to starting time
	curTime = startTime + datetime.timedelta(0,viz.tick()-startTick)
	print curTime.strftime('%H:%M:%S:%f')

vizact.ontimer(0.1, LogTime)
Keep in mind that writing to a file in the main rendering loop can cause drops in your framerate. You might want to consider moving your file writing code to a different thread.
Reply With Quote