Skip to content

Instantly share code, notes, and snippets.

@howiemnet
Created July 17, 2016 19:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save howiemnet/8f617ff7b4845161fe7ebeb64ceba5dd to your computer and use it in GitHub Desktop.
Save howiemnet/8f617ff7b4845161fe7ebeb64ceba5dd to your computer and use it in GitHub Desktop.
# Motion export script
rad2deg = 180/3.14159265
import bpy
import math
from math import sqrt
sce = bpy.context.scene
saveFile = open("/Users/h/Documents/BlenderPlayback.csv","w")
#maxDelta = 0.2
sce.frame_set(sce.frame_start)
saveFile.write("FRAME,BIGSLIDER,PAN,TILT,MTURN,FOCUS\n")
for fr in range(sce.frame_start, sce.frame_end+1):
sce.frame_set(fr)
sce.update()
xSlider = bpy.data.scenes[0].objects["SliderDummy"].location[0] - bpy.data.scenes[0].objects["SliderDummy.001"].location[0]
xPan = bpy.data.scenes[0].objects["PTR_PAN"].matrix_world.to_euler("XYZ")[1]
xTilt = - bpy.data.scenes[0].objects["PTR_TILT"].matrix_world.to_euler("XYZ")[1]
mTurn = bpy.data.scenes[0].objects["MTURN"].matrix_world.to_euler("XYZ")[2]
mFocus = -(bpy.data.scenes[0].objects["FocusDistanceDummy"].location[2])
# xIris = bpy.data.scenes[0].objects["IrisEmpty"].scale[0]
# xSlider = bpy.data.scenes[0].objects["Slider"].location[0]
# xLegoRot = bpy.data.scenes[0].objects["LegoRot"].rotation_euler[2]
saveFile.write(str(fr))
saveFile.write(",")
saveFile.write(str(xSlider))
saveFile.write(",")
saveFile.write(str(xPan * rad2deg))
saveFile.write(",")
saveFile.write(str(xTilt * rad2deg))
saveFile.write(",")
saveFile.write(str(mTurn * rad2deg))
saveFile.write(",")
saveFile.write(str(mFocus))
saveFile.write("\n")
saveFile.close()
@howiemnet
Copy link
Author

OK, so this is a Python script to export the positions, rotations, or focus distance of a virtual camera rig, as a CSV file with one line per frame. Everything's hardcoded, in order to reduce portability and convenience. But that's how we leave something for version 2.0 to do, eh...

For more information about what this is for, see the motion control server Readme, here -> https://github.com/howiemnet/MotionControl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment