Thread: text output
View Single Post
Old 10-23-2007, 10:46 AM
farshizzo farshizzo is offline
WorldViz Team Member
Join Date: Mar 2003
Posts: 2,849
You are opening the file during every iteration of your timer, this is very inefficient. Also, whenever you open a file in write mode (i.e. 'w') it will overwrite the current contents of the file. What you should do is open the file once, and just write to it inside your timer. Example:
logFile = open ('time.txt','w')
def RecordTimer(pos, currentTime):
	currentTime = viz.tick()
	pos = gball.getPosition()
	save = '%d %.4f %.4f %.4f'%(currentTime * 1000,pos[0],pos[1],pos[2])###original
	print save
Also, if you want to append data to a file, you can open it using the 'a' flag, instead of the 'w' flag.
Reply With Quote