Skip to content

Instantly share code, notes, and snippets.

@howiemnet
Created July 27, 2017 10:14
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save howiemnet/9252ec2fd15c51e4f708c3a535f194fc to your computer and use it in GitHub Desktop.
Save howiemnet/9252ec2fd15c51e4f708c3a535f194fc to your computer and use it in GitHub Desktop.
Houdini to After Effects animation exporter thingy
# first hacky attempt at getting camera / object animations into AE from Houdini.
# Stick this on a tool button on a shelf. Note the hard-coding below (!)
# A file will be created in your home folder; open it, copy to the clipboard, then go to AE and paste onto the cam/null of your choice
import hou
h = hou.node("/obj/geo1")
filename = "testfile.txt"
startFrame = 0
endFrame = 300
scale = 100.0
with open(filename,"w") as ff:
ff.write("Adobe After Effects 8.0 Keyframe Data\n\n")
ff.write("\tUnits Per Second\t25\n")
ff.write("\tSource Width\t1920\n")
ff.write("\tSource Height\t804\n")
ff.write("\tSource Pixel Aspect Ratio\t1\n")
ff.write("\tComp Pixel Aspect Ratio\t1\n")
# do the orientation:
ff.write("\nTransform\tOrientation\n")
ff.write("\tFrame\tX degrees\t\n")
for theFrame in range (startFrame,endFrame):
x = h.worldTransformAtTime(hou.frameToTime(theFrame))
xform = x.extractRotates('srt','zyx',hou.Vector3())
ff.write("\t"+str(theFrame)+"\t"+str(xform[0])+"\t"+str(-xform[1])+"\t"+str(-xform[2])+"\n")
# do the positions:
ff.write("\nTransform\tPosition\n")
ff.write("\tFrame\tX pixels\tY pixels\tZ pixels\n")
for theFrame in range (startFrame,endFrame):
x = h.worldTransformAtTime(hou.frameToTime(theFrame))
xform = x.extractTranslates('srt')
ff.write("\t"+str(theFrame)+"\t"+str(xform[0]*scale)+"\t"+str(-xform[1]*scale)+"\t"+str(-xform[2]*scale)+"\n")
ff.write("\nEnd of Keyframe Data\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment