#******************************************************
# Save Camera Data to a CSV file
#
# - savecameradata.py
# - By Mark Caldwell
# - Version 0.4
# - 18th October 2020
# - Copyright Mark Caldwell 2006
# - Tested with Vue R5 (2020)
#
# How to use in 4 easy steps
#
# 1. Download this file onto your computer
#
# 2. Change Path to Saved File
#
# 3. Then run script and wait for it to work
# To run it go to Python -> Run Python Script
# Then locate the file on your computer
#
# 4. Camera path and rotation are now stored in the CSV
# File and can be loaded using loadcameradata.csv
#
#******************************************************
#------------------------------------------------------------------
# Filename to Save Data To - Change as required for your computer
#------------------------------------------------------------------
#filename="C:/Users/foo/Documents/e-on software/camera.csv"
#----------------------------------------------
# Internal Variables Set Up: Don't alter these
#----------------------------------------------
end=0
frames=[]
currentframe=0
oldframe=currentframe+1
SetCurrentFrame (0)
#----------------------------------------------
# Find the camera
#----------------------------------------------
SelectByType(VuePython.VOT_Camera)
camobj = GetSelectedObjectByIndex(0)
cam=camobj.ToCamera()
#----------------------------------------------
# Find the first key frame if it comes before
# frame 0
#----------------------------------------------
SetCurrentFrame(currentframe)
while end==0:
PreviousKeyFrame ()
currentframe=CurrentFrame ()
if currentframe<oldframe:
oldframe=currentframe
else:
end=1
#----------------------------------------------
# Step through key frames and read camera info
#----------------------------------------------
end=0
oldframe=currentframe-2
SetCurrentFrame(currentframe-1)
framecount=0
while end==0:
NextKeyFrame ()
currentframe=CurrentFrame ()
if currentframe>oldframe:
oldframe=currentframe
pos=camobj.Position()
rot=camobj.GetRotationAngles()
dof=cam.DepthOfField()
exp=cam.Exposure ()
foc=cam.Focal ()
focdis=cam.FocusDistance ()
abr=cam.LensAberration ()
hor=cam.HorizontalFilmShift()
ver=cam.VerticalFilmShift ()
frames.append([currentframe,pos[0],pos[1],pos[2],rot[0],rot[1],rot[2],dof,exp,foc,focdis,abr,hor,ver])
framecount=framecount+1
else:
end=1
#----------------------------------------------
# Write out camera data to file
#----------------------------------------------
output=open (filename,'w')
for f in frames:
if framecount==1:
f[0]=0
line=str(f[0])+','+str(f[1])+','
for n in range (2,14):
line=line+str(float(f[n]))
if n<13:
line=line+','
else:
line=line+'\n'
output.write(line)
output.close()
Refresh ()
#----------------------------------------------
# End of Script
#----------------------------------------------