Created
July 18, 2018 05:00
-
-
Save K240-zz/4188373f506963368318787cabe4861a to your computer and use it in GitHub Desktop.
Export Nuke chan
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
import pymel.core as pm | |
import math | |
def exportCameraChan(obj, st, ed, filename): | |
bt = pm.currentTime( query=True ) | |
fd = open(filename, 'wt') | |
for i in range(ed-st): | |
pm.currentTime(i+st) | |
t = obj.getTranslation() | |
r = obj.getRotation() | |
vfov = 2 * (math.atan2(obj.getVerticalFilmAperture()/2.0*25.4,obj.getFocalLength()) * 180 / math.pi); | |
ap = math.tan(obj.getHorizontalFieldOfView()/2*(math.pi/180)) * obj.getFocalLength()* 2 | |
# folowing name of channel for Nuke. | |
# tx ty tz rx ry rz aperture focal | |
fd.write( "%d\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n" % (i+st, t[0], t[1], t[2], r[0], r[1], r[2], vfov ) ) | |
fd.close() | |
pm.currentTime(bt) | |
filename = pm.fileDialog( dfn='camera.chan', dm='*.chan', mode=1 ) | |
if filename: | |
st = pm.playbackOptions(query=True, minTime=True) | |
ed = pm.playbackOptions(query=True, maxTime=True) | |
# need selected camera | |
exportCameraChan(pm.selected()[0], int(st), int(ed), filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment