-
-
Save howiemnet/8784cf04568c849271730965eaf35159 to your computer and use it in GitHub Desktop.
# Ultra quick'n'hacky AE camera animation importer for Houdini. | |
# Create a new shelf, create a new tool, paste this into the script box. | |
# | |
# In AE, select the Orientation and/or Position keyframes, and Ctrl/Cmd-C them to the clipboard | |
# Open a new text file (Notepad or Textedit) and paste the clipboard contents in. There's your keyframes. | |
# Save the text file somewhere and amend the filename line below to suit | |
# In Houdini, create a camera (it's up to you to set the same zoom / aperture as the AE one). | |
# ... and run this script (well, press the shelf button you stuck this on) | |
import hou | |
# amend the next two lines as required | |
h = hou.node("/obj/cam1") | |
filename = "cameraKeyFrameData.txt" | |
state = "crap" | |
ignoreLine = False | |
with open (filename,"rU") as ff: | |
for theLine in ff: | |
elements = theLine.strip().split("\t") | |
ignoreLine = False | |
if len(elements) == 0: | |
state = "crap" | |
ignoreLine = True | |
else: | |
if elements.count("X degrees") > 0: | |
state = "orientation" | |
ignoreLine = True | |
if elements.count("X pixels") > 0: | |
state = "translate" | |
ignoreLine = True | |
if ignoreLine == False: | |
if len(elements) == 4: | |
theFrame = elements[0] | |
theXValue = elements[1] | |
theYValue = elements[2] | |
theZValue = elements[3] | |
if state == "translate": | |
print ("At frame "+theFrame+" translate to: "+theXValue) | |
setKey = hou.Keyframe() | |
setKey.setFrame(int(theFrame)) | |
setKey.setValue(float(theXValue)*0.01) | |
testCh = hou.parm("obj/cam1/tx") | |
testCh.setKeyframe(setKey) | |
setKey = hou.Keyframe() | |
setKey.setFrame(int(theFrame)) | |
setKey.setValue(-float(theYValue)*0.01) | |
testCh = hou.parm("obj/cam1/ty") | |
testCh.setKeyframe(setKey) | |
setKey = hou.Keyframe() | |
setKey.setFrame(int(theFrame)) | |
setKey.setValue(-float(theZValue)*0.01) | |
testCh = hou.parm("obj/cam1/tz") | |
testCh.setKeyframe(setKey) | |
if state == "orientation": | |
print ("At frame "+theFrame+" orient to: "+theXValue) | |
setKey = hou.Keyframe() | |
setKey.setFrame(int(theFrame)) | |
setKey.setValue(float(theXValue)) | |
testCh = hou.parm("obj/cam1/rx") | |
testCh.setKeyframe(setKey) | |
setKey = hou.Keyframe() | |
setKey.setFrame(int(theFrame)) | |
setKey.setValue(-float(theYValue)) | |
testCh = hou.parm("obj/cam1/ry") | |
testCh.setKeyframe(setKey) | |
setKey = hou.Keyframe() | |
setKey.setFrame(int(theFrame)) | |
setKey.setValue(-float(theZValue)) | |
testCh = hou.parm("obj/cam1/rz") | |
testCh.setKeyframe(setKey) | |
Hi friend. With your permission, I have a little finalized your idea. Now you do not need to save the txt file. The camera animation is immediately copied from the buffer.
Hi friend. With your permission, I have a little finalized your idea. Now you do not need to save the txt file. The camera animation is immediately copied from the buffer.
Heh - nice - but makes it platform dependent though. I'll try and get round to doing something a bit better. Tidiest solution would be to just grab the clipboard contents straight into a string and deal with it there.
Heh - nice - but makes it platform dependent though. I'll try and get round to doing something a bit better. Tidiest solution would be to just grab the clipboard contents straight into a string and deal with it there.
I didn’t quite manage to do this, because the buffer encoding adds extra tabs. But it will be very nice to look at your option
Houdini shows me an error when i run this code, that is- "ValueError: invalid literal for int() with base 10: ''.
I found that replacing "setKey.setFrame(int(theFrame))" with "setKey.setFrame(int(float(theFrame)))" solves the problem.
Hey!! my camera was in the wrong direction and i don't understand how to correct it
thanks a lot for the script + your process comment : very helpfull for a newbie !!!
++