Created
July 27, 2017 10:14
-
-
Save howiemnet/9252ec2fd15c51e4f708c3a535f194fc to your computer and use it in GitHub Desktop.
Houdini to After Effects animation exporter thingy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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